13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix BA Java Swing GUI for BudgetPro533265 }266 }267 };268 creat.addActi<strong>on</strong>Listener(creatActi<strong>on</strong>);269270 // functi<strong>on</strong> is to get selecti<strong>on</strong> from table and cd there271 view.addActi<strong>on</strong>Listener(cdActi<strong>on</strong>);272 // but it starts off disabled, since there is no data yet273 view.setEnabled(false);274275 // ------------------------------------------------------------276 frame.getRootPane().setDefaultButt<strong>on</strong>(creat);277 clos.grabFocus();278279 return retval;280281 } // createButt<strong>on</strong>s282283 public static void284 main(String[] args)285 {286 BudgetPro app = null;287288 //Create the top-level c<strong>on</strong>tainer289 JFrame frame = new JFrame("BudgetPro");290291 // ----------- set up the account/app based <strong>on</strong> the command line args292 try {293 String username = System.getProperty("user.name", "default");294 if (args.length > 0) {295 app = new BudgetPro(frame, username, args[0]);296 } else {297 System.err.println("usage: BudgetPro dollar_amt");298 System.exit(1);299 }300 } catch (Excepti<strong>on</strong> e) {301 System.err.println("Error <strong>on</strong> startup.");302 e.printStackTrace();303 System.exit(2);304 }305306 // ----------- now set up the UI and get things going307 try {308 UIManager.setLookAndFeel(309 UIManager.getCrossPlatformLookAndFeelClassName());310 } catch (Excepti<strong>on</strong> e) {311 System.err.println("Can't set the desired look and feel.");312 e.printStackTrace();313 System.exit(3);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!