Java Reference
In-Depth Information
The
JTextArea
defines a component that allows editing of multi-line text.
This is an example of a
JTextArea
component.
The scrollbars are supplied automatically and you
can also display multiple rows and columns.
The
JEditPane
and
JTextPane
components are a different order of complexity from the others and
enable you to implement sophisticated editing facilities relatively easily. The
JEditPane
supports editing of
plain text, text in HTML, and RTF (Rich Text Format). The
JTextPane
class extends
JEditPane
and
allows you to embed images or other components within the text managed by the component.
Other Swing Components
Other Swing components you will use regularly include the
JPanel
component. The
JPanel
class
defines something like a physical panel that you can use to group a set of components. For instance, you
might use two
JPanel
objects to support two separate groups of
JButton
components in the content
pane of an application window.
The
JList
and
JTable
components are also very useful.
This is a
JList
component that implements a list of items. This
component has a border of type
EtchedBorder
added to it. You can
select entries from the list.
This is a
JTable
component that implements a
table of items from which you can select a row, or
a column, or a single element. A
JTable
component automatically takes care of reordering
the columns when a column is dragged to a new
position using the mouse.
Any component can have a border added, and the
javax.swing.borders
package contains eight
classes representing different kinds of borders you can use for a component.
We have not introduced all the Swing component classes by any means, and you will be meeting a few
more as you progress through the rest of the topic.