17.9. Summary

In this chapter you have learned how to create an application window, and how to use containers in the creation of the GUI for a program. I discussed the following important points:

  • The package javax.swing provides classes for creating a graphical user interface (GUI).

  • A component is an object that is used to form part of the GUI for a program. All components have the class Component as a superclass.

  • A container is a component that can contain other components. A container object is created with a class that is a subclass of Container. The classes JPanel, JApplet, JWindow, JFrame, and JDialog are containers.

  • The class JApplet is the base class for an applet. The JFrame class is a base class for an application window with a title bar, borders, and a menu.

  • The arrangement of components in a container is controlled by a layout manager.

  • The default layout manager for the content pane of JFrame, JApplet, and JDialog objects is BorderLayout.

  • The GridBagLayout provides the most flexible control of the positioning of components in a container. The position of a component in a GridBagLayout is controlled by a GridBagConstraints object.

  • A Box container can be used to arrange components or containers in rows and columns. You can use multiple nested Box containers in combination to easily create complex arrangements that otherwise might require GridBagLayout to be used.

  • A layout manager of type SpringLayout arranges components by applying constraints in the form of Spring objects to ...

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.