General reminders |
To display a Swing component, you must:
Container contentPane = getContentPane(); contentPane.add (button); ... contentPane.validate();
To handle events from a GUI component, you must do the following:
When the listener method is called, you can find out which component sent the event by calling getSource() on the event.
public void actionPerformed (ActionEvent event) { Object theButton = event.getSource(); if (theButton == framedCircleButton) { // Create a framed circle } }
If a method returns a String or Object, remember to compare the result using the equals method, not ==: aMenu.getSelectedItem ().equals ("A value")
General reminders |