Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Components

 
The basic idea in creating a GUI is to start with the components, add the container(s), then decide upon the layout. See the chapters on the last two items for additional information. Some examples are presented in the GUIs chapter.
 
Java relies heavily on inheritance and interfaces. In order to understand the concepts it is useful to consider the hierarchy. An abbreviated package structure is presented below. A dotted line indicates inheritance. Note that only a partial listing of classes (those used in this course)
are listed.

 

Note that since javax Components inherit from java containers, javax Components are also Containers. This allows the user to create some very sophisticated arrangements. 
A summary of uses-capabilities is also provided at the bottom of the page.

 

Java Component
Description

 

Button
A graphical push button
Canvas
A component that displays a blank canvas, allowing a program to display custom graphics.
Component
The base class for all AWT and Swing components. Defines many basic methods inherited by all components.
Label
Displays a single line of read-only text. Does not respond to user input in any way.
Scrollbar
A graphical scrollbar
TextArea
Displays multiple lines of text and allows the user to edit the text.
TextComponent
The base class for both TextArea and TextField.
TextField
Displays a single line of plain text and allows the user to edit the text.

 

 

Javax Component
Description

 

JButton
A push button that can display text, images, or both.
JCheckBox
A toggle button for displaying choices that are not mutually exclusive
JComboBox
A combination of a text entry field and a drop-down list of choices. The user can type a selection or choose one from the list.
JComponent
The root of the Swing component hierarchy. Adds Swing-specific features.
JLabel
A simple component that displays text, an image, or both. Does not respond to input.
JList
Allows a selectable list of choices.
JOptionPane
Component suitable for displaying simple dialog boxes.
JRadioButton
Toggle button for displaying mutually exclusive choices.
JScrollBar
Horizontal or vertical scroll bar.
JSlider
A component that simulates a slider. Allow the user to select a numeric value by dragging a knob.
JTextArea
Component for displaying and editing multiple lines of plain text.
JTextField
Component for the display, input, and editing of a single line of plain text.