About Swing JavaBeans Components

Swing components are lightweight components that are self-rendering and do not use Windowing resources as do AWT components. In many cases, these components have corresponding AWT components, but the Swing version is enhanced to allow greater flexibility and consistency between platforms.

Note: Swing components rely on underlying functionality in Swing containers. If you intend to use Swing JavaBeans, you must create your program using a JFrame, JPanel or other container that implements the basic Swing functionality.

Component

Description

JButton

A simple push button. A JButton can have an embedded icon.

JCheckBox

A square box used to display boolean (true/false) values. When its value is set to true, the box displays a checkmark by default. You have the option of setting your own checkmark graphic.

JComboBox

Similar to the Choice control in AWT, displays a list of values that the user can select at runtime. JComboBox has the property editable which enables the user to type a new value at runtime.

JEditorPane

A specialized JTextComponent that displays text formatted with HTML 3.2 or RTF. It is intended to allow you to create help pages for your application or applet.

JLabel

A text component that enables you to display a text string and optional icon. Additional properties enable you to set the position of the text relative to the icon.

JList

Displays a list of objects.

Tip: The JList, unlike the AWT List component, doesn't have a scrolling facility built into the component. To make a scrollable list, you need to drop the list component into a JScrollPane container.

JPasswordField

A JTextField that by default displays asterisks (*) in place of the characters entered by the user.

JProgressBar

Displays a progress bar that graphically depicts the percentage of completion for a process.

JRadioButton

This component is specifically designed to behave as a Radio Button. When grouped with other JRadioButtons in a ButtonGroup, only one of the buttons in the group can be selected at one time. The ButtonGroup is a non-visual component.

JScrollBar

A graphic control the user can use to set an integer value. This component can be displayed with either a horizontal or a vertical orientation.

JSeparator

A component that draws a straight line. It is intended to be used as a component in a JMenu, but since it is an actual component, you can use it to draw a line in your UI that separates one set of controls from another. The JSeparator can be displayed in vertical or horizontal orientation.

JSlider

Similar to a JScrollBar, this control allows the user to set an integer value using a graphic control. JSlider allows you to set major and minor tick marks, and to display a border around the control.

JTable

Displays information in a two-dimensional grid, similar to a spreadsheet application.

Tip: The JTable, unlike the AWT List component, doesn't have a scrolling facility built into it. To make a scrollable table, you need to drop the list component into a JScrollPane container.

JTextArea

An editable text area that displays a single string in multiple rows, each of which ends in a newline character.

Tip: In order to make a JTextArea scrollable, it needs to be displayed in a JScrollPane container.

JTextField

An editable text area that displays a single string in a single row.

JTextPane

A full-featured text editor control that enables word wrap, image display, and style definition.

Tip: In order to make a JTextPane scrollable, it needs to be dropped in a JScrollPane container.

JTree

Displays hierarchical information, such as file directories, in a tree format.

Tip: The JTree, unlike the AWT List component, doesn't have a scrolling facility built into it. To make a scrollable tree, you need to drop the list component into a JScrollPane container.

JToggleButton

Toggle buttons are similar to JCheckBox controls. When they are pushed (set to true) they remain true until they are set to false by pressing them again. JToggleButtons can be placed in a ButtonGroup so that only one in the group can be true at one time. Toggle buttons are useful in toolbars to display a tool in an active state. The buttons in the Component Palette are examples of toggle buttons.

For more information on Swing components, go to this Sun Microsystems web page:

http://java.sun.com/products/jfc/tsc/articles/component_gallery/


About Containers
About Component Properties in the Inspector
Working with Components in a Container
Working with Applets