Java Reference
In-Depth Information
}
}
Panel textPanel;
Frame frame;
public ShoppingChart() {
frame = new Frame("Shopping Chart");
MenuBar menuBar = new MenuBar();
Menu menu = new Menu ("Items");
MenuItem insertItem = new MenuItem ("insert");
insertItem.addActionListener(this);
menu.add(insertItem);
menuBar.add(menu);
frame.setMenuBar (menuBar);
textPanel = new Panel(new GridLayout (0, 2));
frame.add(textPanel, BorderLayout.NORTH);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent e) {
destroyApp(true);
}
} );
frame.pack();
}
public void actionPerformed(ActionEvent ae) {
InsertItemDialog dialog = new InsertItemDialog(frame);
dialog.show();
textPanel.add(new Label (dialog.getAmount()));
textPanel.add(new Label (dialog.getItem()));
frame.validate();
}
public void startApp() {
frame.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
}
Figure 4.7 shows a shopping chart that is displayed using the GridLayout of the java.awt
package.
Figure 4.7. The ShoppingChart application showing a shopping list layout using the
GridLayout .
 
 
Search WWH ::




Custom Search