Java UI Components

PGUI: Java UI components

This page gives a general description of the Java user interface components. The details of the individual components classes can be studied using example programs and Java 2 API documentation.

Component classes

The class diagrams below does not include all Java UI components. However, they give you basic understanding on the class hierarchy.

The base class of all user interface components is java.awt.Component. Its direct subclasses are the simple "Abstract Windowing Toolkit" (AWT) components, and also java.awt.Container, the superclass of every component that can act as a container of other components.

The Swing components are subclasses of java.awt.Container. Thus, they can contain other components.The super class of the Swing components is javax.swing.JComponent. It is abstract but subclasses can be concrete without implementing any virtual functions. Although all swing classes can be container there are some that refuse children (like javax.swing.JButton). The simplest concrete subclass of JComponent is javax.swing.JPanel adding no functionality to JComponent.

Window classes

The window classes represent top-level windows. They are also components and specifically, containers. The superclass of window classes is java.awt.Window.

The class java.awt.Frame represents a top-level application window that can have a menu bar.

The Swing window classes do not have a single superclass. They extend the corressponding class from java.awt.

Examples

ComponentDemo example program demonstrates the use of buttons and lists. In addition, it uses java.awt.GridBagLayout and javax.swing.Box.

LayoutDemo demonstrates the basic layoutn managers in a compact way.

 

See also:
LayoutDemo for Java
ComponentDemo example