Part 5
Swing
This part presents reference information for Java classes that use Swing to create programs that use a graphical user interface. Swing is a Java graphic user interface (GUI) widget toolkit. You use Swing programs to display windows; dialog boxes; and user interface controls; such as labels, buttons, check boxes, and drop-down lists. Swing is a standard part of Java, so you don’t have to download anything extra to use it.
Two important classes you should look at first in this part are JFrame
and JPanel
. You use the JFrame
class to create an object called a frame, which displays in a window. To add content to the window, you create a panel using the JPanel
class. A panel represents a visual region that contains one or more controls such as text boxes, buttons, and labels. To create a GUI application, you first create a frame. Then, you create one or more panels and add controls to the panels. Finally, you add the panels to the frame and then display the frame. For specific information about frames and panels, see JFrame Class and JPanel Class.
In this part . . .
Classes for creating frames and panels
Classes for creating user interface controls
Handling events, such as button clicks
Displaying standard dialog boxes with JFileChooser
and JOptionPane