|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
javax.swing.JComponent
, MenuContainer
, Serializable

, BasicInternalFrameTitlePane
, Box
, Box.Filler
, JColorChooser
, JComboBox
, JFileChooser
, JInternalFrame
, JInternalFrame.JDesktopIcon
, JLabel
, JLayeredPane
, JList
, JMenuBar
, JOptionPane
, JPanel
, JPopupMenu
, JProgressBar
, JRootPane
, JScrollBar
, JScrollPane
, JSeparator
, JSlider
, JSpinner
, JSplitPane
, JTabbedPane
, JTable
, JTableHeader
, JTextComponent
, JToolBar
, JToolTip
, JTree
, JViewport

public abstract class JComponent


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:
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(java.lang.Object, java.lang.Object)
and getClientProperty(java.lang.Object)
methods,
you can associate name-object pairs
with any object that descends from JComponent.
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 JTables 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:
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 JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
KeyStroke
,
Action
,
setBorder(javax.swing.border.Border)
,
registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
,
JOptionPane
,
setDebugGraphicsOptions(int)
,
setToolTipText(java.lang.String)
,
setAutoscrolls(boolean)
,
Serialized Form| Nested Class Summary | |
|---|---|
class |
JComponent.AccessibleJComponent
Inner class of JComponent used to provide default support for accessibility. |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary | |
|---|---|
protected AccessibleContext |
accessibleContext
The AccessibleContext associated with this
JComponent. |
protected EventListenerList |
listenerList
A list of event listeners for this component. |
static String |
TOOL_TIP_TEXT_KEY
The comment to display when the cursor is over the component, also known as a "value tip", "flyover help", or "flyover label". |
protected ComponentUI |
ui
The look and feel delegate for this component. |
static int |
UNDEFINED_CONDITION
Constant used by some of the APIs to mean that no condition is defined. |
static int |
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
Constant used for registerKeyboardAction that
means that the command should be invoked when the receiving
component is an ancestor of the focused component or is
itself the focused component. |
static int |
WHEN_FOCUSED
Constant used for registerKeyboardAction that
means that the command should be invoked when
the component has the focus. |
static int |
WHEN_IN_FOCUSED_WINDOW
Constant used for registerKeyboardAction that
means that the command should be invoked when
the receiving component is in the window that has the focus
or is itself the focused component. |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JComponent
Default JComponent constructor. |
|
| Method Summary | ||
|---|---|---|
void |
addAncestorListener
Registers listener so that it will receive
AncestorEvents when it or any of its ancestors
move or are made visible or invisible. |
|
void |
addNotify
Notifies this component that it now has a parent component. |
|
void |
addVetoableChangeListener
Adds a VetoableChangeListener to the listener list. |
|
void |
computeVisibleRect
Returns the Component's "visible rect rectangle" - the
intersection of the visible rectangles for this component
and all of its ancestors. |
|
boolean |
contains
Gives the UI delegate an opportunity to define the precise shape of this component for the sake of mouse processing. |
|
JToolTip |
createToolTip
Returns the instance of JToolTip that should be used
to display the tooltip. |
|
void |
disable
Deprecated. As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean). |
|
void |
enable
Deprecated. As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean). |
|
void |
firePropertyChange
Support for reporting bound property changes for boolean properties. |
|
void |
firePropertyChange
Reports a bound property change. |
|
void |
firePropertyChange
Support for reporting bound property changes for integer properties. |
|
protected void |
fireVetoableChange
Supports reporting constrained property changes. |
|
AccessibleContext |
getAccessibleContext
Returns the AccessibleContext associated with this
JComponent. |
|
ActionListener |
getActionForKeyStroke
Returns the object that will perform the action registered for a given keystroke. |
|
ActionMap |
getActionMap
Returns the ActionMap used to determine what
Action to fire for particular KeyStroke
binding. |
|
float |
getAlignmentX
Overrides Container.getAlignmentX to return
the vertical alignment. |
|
float |
getAlignmentY
Overrides Container.getAlignmentY to return
the horizontal alignment. |
|
AncestorListener |
getAncestorListeners
Returns an array of all the ancestor listeners registered on this component. |
|
boolean |
getAutoscrolls
Gets the autoscrolls property. |
|
Border |
getBorder
Returns the border of this component or null if no
border is currently set. |
|
Rectangle |
getBounds
Stores the bounds of this component into "return value" rv and returns rv. |
|
Object |
getClientProperty
Returns the value of the property with the specified key. |
|
protected Graphics |
getComponentGraphics
Returns the graphics object used to paint this component. |
|
JPopupMenu |
getComponentPopupMenu
Returns JPopupMenu that assigned for this component. |
|
int |
getConditionForKeyStroke
Returns the condition that determines whether a registered action occurs in response to the specified keystroke. |
|
int |
getDebugGraphicsOptions
Returns the state of graphics debugging. |
|
static Locale |
getDefaultLocale
Returns the default locale used to initialize each JComponent's locale property upon creation. |
|
FontMetrics |
getFontMetrics
Gets the FontMetrics for the specified Font. |
|
Graphics |
getGraphics
Returns this component's graphics context, which lets you draw on a component. |
|
int |
getHeight
Returns the current height of this component. |
|
boolean |
getInheritsPopupMenu
Returns true if the JPopupMenu should be inherited from the parent. |
|
InputMap |
getInputMap
Returns the InputMap that is used when the
component has focus. |
|
InputMap |
getInputMap
Returns the InputMap that is used during
condition. |
|
InputVerifier |
getInputVerifier
Returns the input verifier for this component. |
|
Insets |
getInsets
If a border has been set on this component, returns the border's insets; otherwise calls super.getInsets. |
|
Insets |
getInsets
Returns an Insets object containing this component's inset
values. |
|
|
getListeners
Returns an array of all the objects currently registered as FooListeners
upon this JComponent. |
|
Point |
| |