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.

532Appendix BA Java Swing GUI for BudgetPro216 } // createList217218 private Comp<strong>on</strong>ent219 createButt<strong>on</strong>s(JRootPane root)220 {221 JPanel retval = new JPanel(); // default: flow layout222223 //Lay out the butt<strong>on</strong>s from left to right.224 retval.setLayout(new BoxLayout(retval, BoxLayout.X_AXIS));225 retval.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));226 retval.add(Box.createHoriz<strong>on</strong>talGlue());227 retval.add(creat);228 retval.add(Box.createRigidArea(new Dimensi<strong>on</strong>(10, 0)));229 retval.add(view);230 retval.add(Box.createRigidArea(new Dimensi<strong>on</strong>(10, 0)));231 retval.add(clos);232233 // ---------------------------------------- Define some acti<strong>on</strong>s234 Acti<strong>on</strong>Listener closActi<strong>on</strong> = new Acti<strong>on</strong>Listener()235 {236 public void237 acti<strong>on</strong>Performed(Acti<strong>on</strong>Event e)238 {239 System.exit(0);240 }241 } ;242 clos.addActi<strong>on</strong>Listener(closActi<strong>on</strong>);243244 Acti<strong>on</strong>Listener creatActi<strong>on</strong> = new Acti<strong>on</strong>Listener()245 {246 public void247 acti<strong>on</strong>Performed(Acti<strong>on</strong>Event e)248 {249 Account child;250 // get the info via a Dialog (of sorts)251 if (askem == null) {252 askem = new AcctDialog(frame, "New Subaccount");253 } else {254 askem.clear();255 askem.setVisible(true);256 }257 String subName = askem.getName();258 String subAmnt = askem.getAmnt();259260 // if empty, assume the operati<strong>on</strong> was cancelled, else:261 if ((subName != null) && (subName.length() > 0)) {262 child = current.createSub(subName, subAmnt);263 setStatus();264 model.fireTableDataChanged(); // notify the table

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

Saved successfully!

Ooh no, something went wrong!