The base class for all Swing components except top-level containers.
To use a component that inherits from JComponent
,
you must place the component in a containment hierarchy
whose root is a top-level Swing container.
Top-level Swing containers --
such as JFrame
, JDialog
,
and JApplet
--
are specialized components
that provide a place for other Swing components to paint themselves.
For an explanation of containment hierarchies, see
Swing Components and the Containment Hierarchy,
a section in The Java Tutorial.
The JComponent
class provides:
javax.swing.plaf.ComponentUI
.
See How
to Set the Look and Feel
in The Java Tutorial
for more information.
JComponent
contains all of the methods in the
Accessible
interface,
but it doesn't actually implement the interface. That is the
responsibility of the individual classes
that extend JComponent
.
putClientProperty
and getClientProperty
methods,
you can associate name-object pairs
with any object that descends from JComponent
.
Swing package description
and The Java Tutorial section
The JComponent Class.
JComponent
and its subclasses document default values
for certain properties. For example, JTable
documents the
default row height as 16. Each JComponent
subclass
that has a ComponentUI
will create the
ComponentUI
as part of its constructor. In order
to provide a particular look and feel each
ComponentUI
may set properties back on the
JComponent
that created it. For example, a custom
look and feel may require JTable
s to have a row
height of 24. The documented defaults are the value of a property
BEFORE the ComponentUI
has been installed. If you
need a specific value for a particular property you should
explicitly set it.
In release 1.4, the focus subsystem was rearchitected. For more information, see How to Use the Focus Subsystem, a section in The Java Tutorial.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans™
has been added to the java.beans
package.
Please see java.beans.XMLEncoder
.
extends
KeyStroke, Action, setBorder, registerKeyboardAction, JOptionPane, setDebugGraphicsOptions, setToolTipText, setAutoscrolls