GUI ComponentsTopGeneral reminders

General reminders

To display a Swing component, you must:

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 ==. For example, aMenu.getSelectedItem ().equals ("A value")


GUI ComponentsTopGeneral reminders