Java Reference
In-Depth Information
labelPanel.add(new Label ("Width: "));
labelPanel.add(new Label ("Height: "));
fieldPanel.add(widthField);
fieldPanel.add(heightField);
cardChoice.add("outline");
cardChoice.add("filled");
buttonPanel.add(cardChoice);
buttonPanel.add(applyButton);
applyButton.addActionListener(this);
cardChoice.addItemListener(this);
Panel controlPanel = new Panel (new BorderLayout());
controlPanel.add(labelPanel, BorderLayout.WEST);
controlPanel.add(fieldPanel, BorderLayout.CENTER);
controlPanel.add(buttonPanel, BorderLayout.EAST);
frame.add(controlPanel, BorderLayout.NORTH);
frame.add(dynPanel, BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing (WindowEvent ev) {
notifyDestroyed();
}
} );
frame.pack();
}
public void itemStateChanged (ItemEvent ev) {
if (ev.getStateChange() == ItemEvent.SELECTED) {
dynPanel.invalidate();
frame.validate();
dynPanel.repaint();
}
}
public void actionPerformed (ActionEvent ev) {
width = Integer.parseInt (widthField.getText());
height = Integer.parseInt (heightField.getText());
rect1.invalidate();
rect2.invalidate();
frame.validate();
}
public void startApp() {
frame.show();
}
public void pauseApp() {
}
public void destroyApp (boolean unconditional) {
Search WWH ::




Custom Search