Java Reference
In-Depth Information
(to be put into net/multitool/gui ) and the package statement on line 1 of
BudgetPro.java :
1 package net.multitool.gui;
16.7.1.1
Take a look at the picture of the BudgetPro GUI. Count the GUI objects that
we need: four buttons, three labels, and let's not forget the (empty at first) table
of subaccounts. These are declared in lines 23-31. (Ignore lines 22 and 32
for now, we'll cover them later. Line 34 declares our dialog—more on that
later, too.)
Instance Variables
21 // gui components
22 private JFrame frame; // needed by dialogs to root themselves
23 private JLabel nam;
24 private JLabel tot;
25 private JLabel val;
26 private JButton upton = new JButton(
new ImageIcon("net/multitool/gui/back.gif"));
27 private JButton creat = new JButton("new subaccount");
28 private JButton view = new JButton("view subaccount");
29 private JButton clos = new JButton("quit");
30
31 private JTable list;
32 private AbstractTableModel model;
33
34 private AcctDialog askem; // make once, use often
16.7.1.2
Skip all the way to the last method of the class, line 289 and following. It's the
main() which gets run when we run this class. If we focus on the major piece
involved in getting our GUI together, it's these lines:
Main
JFrame frame = new JFrame("BudgetPro");
frame.getContentPane().add(status, ...);
frame.getContentPane().add(list, ...);
frame.getContentPane().add(buttons, ...);
We're leaving out lots of intermediate text to emphasize the “real” work.
We create a JFrame , the outermost window object. We add into it all the other
Search WWH ::




Custom Search