Summary
GUIs (graphical user interfaces) are programmed using event-driven programming. In event-driven programming, a user action, like a mouse click, generates an event and that event is automatically passed to an event-handling method that performs the appropriate action.
There are two main ways of building up a GUI using Swing. You can use inheritance to create a derived class of one of the predefined Swing classes, you can build up a GUI by adding components to a container class, or you can do both in defining a single class.
The class JFrame is the Swing class that you use to create a windowing GUI. A windowing GUI is defined as a derived class of the class JFrame.
A button is an object of the class JButton.
When adding components to an object of a container class, such as adding a button to a window, you use the method add. The components in a container are arranged by an object called a layout manager.
For an object of the class JFrame, you do not use the method add with the object. Instead, you use the method getContentPane to produce the content pane of the object and you then use the add method with the content pane.
A panel is a container object that is used to group components inside of a larger container. Panels are objects in the class JPanel.
Text fields (objects of the class JTextField) and text areas (objects of the class JTextArea) are used for text input and output in a GUI constructed with Swing.