APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public abstract Class JComponent

extends Container
implements Serializable, HasGetTransferHandler
Class Inheritance
All Implemented Interfaces
javax.swing.TransferHandler.HasGetTransferHandler, java.io.Serializable
Known Direct Subclasses
javax.swing.JFileChooser, javax.swing.JInternalFrame, javax.swing.JInternalFrame.JDesktopIcon, javax.swing.JLabel, javax.swing.JLayer, javax.swing.JLayeredPane, javax.swing.JList, javax.swing.JTabbedPane, javax.swing.JMenuBar, javax.swing.JOptionPane, javax.swing.JPanel, javax.swing.JPopupMenu, javax.swing.JProgressBar, javax.swing.JRootPane, javax.swing.JScrollBar, javax.swing.JScrollPane, javax.swing.JSeparator, javax.swing.JSlider, javax.swing.JSpinner, javax.swing.JSplitPane, javax.swing.JTable, javax.swing.JToolBar, javax.swing.JToolTip, javax.swing.JTree, javax.swing.JViewport, javax.swing.colorchooser.DiagramComponent, javax.swing.plaf.basic.BasicInternalFrameTitlePane, javax.swing.plaf.metal.MetalTitlePane, javax.swing.plaf.nimbus.TableScrollPaneCorner, javax.swing.table.JTableHeader, javax.swing.text.JTextComponent, com.sun.java.swing.plaf.motif.MotifDesktopPaneUI.DragPane, javax.swing.AbstractButton, javax.swing.Box, javax.swing.Box.Filler, javax.swing.JColorChooser, javax.swing.JComboBox
Annotations
@JavaBean
defaultProperty:UIClassID
@SuppressWarnings:serial
Imports
java.awt.AWTEvent, .AWTKeyStroke, .Color, .Component, .Container, .Dimension, .EventQueue, .FocusTraversalPolicy, .Font, .FontMetrics, .Graphics, .Insets, .KeyboardFocusManager, .Point, .Rectangle, .RenderingHints, .Shape, .Window, java.awt.event.ActionEvent, .ActionListener, .ContainerEvent, .ContainerListener, .FocusEvent, .FocusListener, .InputEvent, .KeyEvent, .MouseEvent, java.beans.BeanProperty, .JavaBean, .PropertyChangeListener, .Transient, .VetoableChangeListener, .VetoableChangeSupport, java.io.IOException, .InvalidObjectException, .ObjectInputStream, .ObjectInputValidation, .ObjectOutputStream, .Serial, .Serializable, java.util.Enumeration, .EventListener, .HashSet, .Hashtable, .Locale, .Set, .Vector, java.util.concurrent.atomic.AtomicBoolean, javax.accessibility.Accessible, .AccessibleComponent, .AccessibleContext, .AccessibleExtendedComponent, .AccessibleKeyBinding, .AccessibleRole, .AccessibleState, .AccessibleStateSet, javax.swing.border.AbstractBorder, .Border, .CompoundBorder, .TitledBorder, javax.swing.event.AncestorEvent, .AncestorListener, .EventListenerList, javax.swing.plaf.ComponentUI, sun.awt.AWTAccessor, .SunToolkit, sun.swing.SwingAccessor, .SwingUtilities2

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 and JDialog -- 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:

For more information on these subjects, see the 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 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.

A JComponent may contain any number of default or initial components as children. This behaviour may change according to look and feel, therefore a JComponent may contain some default or initial components as children for a particular Look and Feel, whereas it may not do so for some other Look and Feel. Within a particular Look and Feel also, this behaviour may change depending upon the configuration properties of the JComponent. In summary, it is not valid to assume a JComponent has no children just because the application did not directly add them.

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.

Authors
Hans Muller, Arnaud Weber
Since
1.2
See Also
KeyStroke, Action, setBorder, registerKeyboardAction, JOptionPane, setDebugGraphicsOptions, setToolTipText, setAutoscrolls

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract class
JComponent.AccessibleJComponent

Inner class of JComponent used to provide default support for accessibility.

pack-priv static class
JComponent.ActionStandin

ActionStandin is used as a standin for ActionListeners that are added via registerKeyboardAction.

pack-priv static class
pack-priv static class
private static class
JComponent.ReadObjectCallback

This object is the ObjectInputStream callback that's called after a complete graph of objects (including at least one JComponent) has been read.

Field Summary

Modifier and TypeField and Description
private transient Object
aaHint

AA text hints.

private ActionMap
actionMap

ActionMap.

private static final int
private float
private float
private static final int
private static final int
private InputMap
ancestorInputMap

Used for WHEN_ANCESTOR_OF_FOCUSED_COMPONENT bindings.

private boolean
autoscrolls

Whether or not autoscroll has been enabled.

private static final int
private Border
private transient ArrayTable
private static final int
private static Component
private static Object
private static final int
pack-priv static boolean
DEBUG_GRAPHICS_LOADED

Set to true when DebugGraphics has been loaded.

private static volatile Locale
private int
private static final int
private static final int
private static final int
pack-priv static final RequestFocusController
private InputMap
focusInputMap

Used for WHEN_FOCUSED bindings.

private static final int
private InputVerifier
private static final JComponent.IntVector
private static final int
IS_DOUBLE_BUFFERED

Private flags

private static final int
private static final int
private static final int
private static final int
private static final int
private boolean
private boolean
pack-priv static JComponent
private static final int
private static final String
KEYBOARD_BINDINGS_KEY

The key used by JComponent to access keyboard bindings.

private transient Object
protected EventListenerList
listenerList

A list of event listeners for this component.

private static Set<KeyStroke>
managingFocusBackwardTraversalKeys

Keys to use for backward focus traversal when the JComponent is managing focus.

private static Set<KeyStroke>
managingFocusForwardTraversalKeys

Keys to use for forward focus traversal when the JComponent is managing focus.

private static final String
private static final int
private static final int
pack-priv transient Component
paintingChild

Set in _paintImmediately.

private static final int
private JPopupMenu
popupMenu

JPopupMenu assigned to this component and all of its children

private static final Hashtable<ObjectInputStream, JComponent.ReadObjectCallback>
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private transient AtomicBoolean
private static List<Rectangle>
tempRectangles

Temporary rectangles.

public static final 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 transient ComponentUI
ui

The look and feel delegate for this component.

private static final String
public static final int
UNDEFINED_CONDITION

Constant used by some of the APIs to mean that no condition is defined.

private boolean
private VetoableChangeSupport
public static final 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.

public static final int
WHEN_FOCUSED

Constant used for registerKeyboardAction that means that the command should be invoked when the component has the focus.

public static final 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.

private static final String
WHEN_IN_FOCUSED_WINDOW_BINDINGS

An array of KeyStrokes used for WHEN_IN_FOCUSED_WINDOW are stashed in the client properties under this string.

private static final int
private ComponentInputMap
windowInputMap

Used for WHEN_IN_FOCUSED_KEY bindings.

private static final int
WRITE_OBJ_COUNTER_FIRST

Bits 14-21 are used to handle nested writeObject calls.

private static final int

Constructor Summary

AccessConstructor and Description
public
JComponent()

Default JComponent constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
_paintImmediately(int x, int y, int w, int h)

public void
addAncestorListener(AncestorListener
the AncestorListener to register
listener
)

Registers listener so that it will receive AncestorEvents when it or any of its ancestors move or are made visible or invisible.

public void
addNotify()

Overrides java.awt.Container.addNotify.

Notifies this component that it now has a parent component.

public synchronized void
addVetoableChangeListener(VetoableChangeListener
the VetoableChangeListener to be added
listener
)

Adds a VetoableChangeListener to the listener list.

private void
pack-priv boolean

Returns:

always returns false
alwaysOnTop
()

Returns whether this component should be guaranteed to be on top.

pack-priv boolean

Returns:

always returns true
checkIfChildObscuredBySibling
()

Returns true, which implies that before checking if a child should be painted it is first check that the child is not obscured by another sibling.

pack-priv void
clientPropertyChanged(Object key, Object oldValue, Object newValue)

pack-priv void
componentInputMapChanged(ComponentInputMap
the map containing the new bindings
inputMap
)

Invoked from ComponentInputMap when its bindings change.

pack-priv static final void
computeVisibleRect(Component
the component
c
,
Rectangle
a Rectangle computed as the intersection of all visible rectangles for the component c and all of its ancestors -- this is the return value for this method
visibleRect
)

Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for the component c and all of its ancestors.

public void
computeVisibleRect(Rectangle
a Rectangle computed as the intersection of all visible rectangles for this component and all of its ancestors -- this is the return value for this method
visibleRect
)

Returns the Component's "visible rect rectangle" - the intersection of the visible rectangles for this component and all of its ancestors.

pack-priv void
compWriteObjectNotify()

This is called from Component by way of reflection.

public boolean

Returns:

true if this component logically contains x,y
contains
(int x, int y)

Overrides java.awt.Component.contains.

Gives the UI delegate an opportunity to define the precise shape of this component for the sake of mouse processing.

public JToolTip

Returns:

the JToolTip used to display this toolTip
createToolTip
()

Returns the instance of JToolTip that should be used to display the tooltip.

private void
public void
disable()

Overrides java.awt.Component.disable.

Deprecated As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean).

pack-priv void
dndDone()

Called to indicate to this component that DnD is done.

pack-priv TransferHandler.DropLocation

Returns:

the drop location, or null
dropLocationForPoint
(Point
the point to calculate a drop location for
p
)

Calculates a custom drop location for this type of component, representing where a drop at the given point should insert data.

public void
enable()

Overrides java.awt.Component.enable.

Deprecated As of JDK version 1.1, replaced by java.awt.Component.setEnabled(boolean).

private static Rectangle
public void
firePropertyChange(String
the property whose value has changed
propertyName
,
boolean
the property's previous value
oldValue
,
boolean
the property's new value
newValue
)

Overrides java.awt.Component.firePropertyChange.

Support for reporting bound property changes for boolean properties.

public void
firePropertyChange(String
the property whose value has changed
propertyName
,
int
the property's previous value
oldValue
,
int
the property's new value
newValue
)

Overrides java.awt.Component.firePropertyChange.

Support for reporting bound property changes for integer properties.

public void
firePropertyChange(String propertyName, char oldValue, char newValue)

Overrides java.awt.Component.firePropertyChange.

Reports a bound property change.

protected void
fireVetoableChange(String
the name of the property that was listened on
propertyName
,
Object
the old value of the property
oldValue
,
Object
the new value of the property
newValue
)

Supports reporting constrained property changes.

public ActionListener

Returns:

the ActionListener object invoked when the keystroke occurs
getActionForKeyStroke
(KeyStroke
the keystroke for which to return a listener
aKeyStroke
)

Returns the object that will perform the action registered for a given keystroke.

public final ActionMap

Returns:

the ActionMap containing the key/action bindings
getActionMap
()

Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding.

pack-priv final ActionMap

Returns:

the ActionMap for this component; if the create flag is false and there is no current ActionMap, returns null
getActionMap
(boolean
if true, create the ActionMap if it is not already created
create
)

Finds and returns the appropriate ActionMap.

public float

Returns:

the value of the alignmentX property
getAlignmentX
()

Overrides java.awt.Container.getAlignmentX.

Overrides Container.getAlignmentX to return the horizontal alignment.

public float

Returns:

the value of the alignmentY property
getAlignmentY
()

Overrides java.awt.Container.getAlignmentY.

Overrides Container.getAlignmentY to return the vertical alignment.

public AncestorListener[]

Returns:

all of the component's AncestorListeners or an empty array if no ancestor listeners are currently registered
getAncestorListeners
()

Returns an array of all the ancestor listeners registered on this component.

private AncestorNotifier
public boolean

Returns:

the value of the autoscrolls property
getAutoscrolls
()

Gets the autoscrolls property.

public int
getBaseline(int width, int height)

Overrides java.awt.Component.getBaseline.

Returns the baseline.

public Component.BaselineResizeBehavior
getBaselineResizeBehavior()

Overrides java.awt.Component.getBaselineResizeBehavior.

Returns an enum indicating how the baseline of the component changes as the size changes.

public Border

Returns:

the border object for this component
getBorder
()

Returns the border of this component or null if no border is currently set.

public Rectangle

Returns:

rv; if rv is null return a newly created Rectangle with this component's bounds
getBounds
(Rectangle
the return value, modified to the component's bounds
rv
)

Overrides java.awt.Component.getBounds.

Stores the bounds of this component into "return value" rv and returns rv.

private ArrayTable

Returns:

an ArrayTable
getClientProperties
()

Returns an ArrayTable used for key/value "client properties" for this component.

public final Object

Returns:

the value of this property or null
getClientProperty
(Object
the being queried
key
)

Returns the value of the property with the specified key.

protected Graphics

Returns:

a Graphics object configured for this component
getComponentGraphics
(Graphics
the original Graphics object
g
)

Returns the graphics object used to paint this component.

public JPopupMenu

Returns:

JPopupMenu assigned for this component or null if no popup assigned
getComponentPopupMenu
()

Returns JPopupMenu that assigned for this component.

public int

Returns:

the action-keystroke condition
getConditionForKeyStroke
(KeyStroke
the keystroke for which to request an action-keystroke condition
aKeyStroke
)

Returns the condition that determines whether a registered action occurs in response to the specified keystroke.

pack-priv boolean

Returns:

true if this component had a double buffer image, false otherwise
getCreatedDoubleBuffer
()

Returns true if the RepaintManager created the double buffer image from the component.

public int

Returns:

a bitwise OR'd flag of zero or more of the following options:
  • DebugGraphics.LOG_OPTION - causes a text message to be printed.
  • DebugGraphics.FLASH_OPTION - causes the drawing to flash several times.
  • DebugGraphics.BUFFERED_OPTION - creates an ExternalWindow that displays the operations performed on the View's offscreen buffer.
  • DebugGraphics.NONE_OPTION disables debugging.
  • A value of 0 causes no changes to the debugging options.
getDebugGraphicsOptions
()

Returns the state of graphics debugging.

public static Locale

Returns:

the default Locale.
getDefaultLocale
()

Returns the default locale used to initialize each JComponent's locale property upon creation.

private boolean
getFlag(int aFlag)

public FontMetrics

Returns:

the font metrics for font
getFontMetrics
(Font
the font for which font metrics is to be obtained
font
)

Overrides java.awt.Component.getFontMetrics.

Gets the FontMetrics for the specified Font.

public Graphics

Returns:

this components graphics context
getGraphics
()

Overrides java.awt.Component.getGraphics.

Returns this component's graphics context, which lets you draw on a component.

pack-priv static void
public int

Returns:

the current height of this component
getHeight
()

Overrides java.awt.Component.getHeight.

Returns the current height of this component.

public boolean

Returns:

true if the JPopupMenu should be inherited from the parent
getInheritsPopupMenu
()

Returns true if the JPopupMenu should be inherited from the parent.

public final InputMap

Returns:

the InputMap for the specified condition
getInputMap
(int
one of WHEN_IN_FOCUSED_WINDOW, WHEN_FOCUSED, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
condition
)

Returns the InputMap that is used during condition.

public final InputMap

Returns:

the InputMap used when the component has focus
getInputMap
()

Returns the InputMap that is used when the component has focus.

pack-priv final InputMap

Returns:

the InputMap for the given condition; if create is false and the InputMap hasn't been created, returns null
getInputMap
(int
one of the following values:
  • JComponent.FOCUS_INPUTMAP_CREATED
  • JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
  • JComponent.WHEN_IN_FOCUSED_WINDOW
condition
,
boolean
if true, create the InputMap if it is not already created
create
)

Returns the InputMap to use for condition condition.

public InputVerifier

Returns:

the inputVerifier property
getInputVerifier
()

Returns the input verifier for this component.

public Insets

Returns:

the value of the insets property
getInsets
()

Overrides java.awt.Container.getInsets.

If a border has been set on this component, returns the border's insets; otherwise calls super.getInsets.

public Insets

Returns:

the Insets object
getInsets
(Insets
the Insets object, which can be reused
insets
)

Returns an Insets object containing this component's inset values.

public <T extends EventListener> T[]

Returns:

an array of all objects registered as FooListeners on this component, or an empty array if no such listeners have been added
getListeners
(Class<T>
the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
listenerType
)

Overrides java.awt.Container.getListeners.

Returns an array of all the objects currently registered as FooListeners upon this JComponent.

public Point

Returns:

rv
getLocation
(Point
the return value, modified to the component's location
rv
)

Overrides java.awt.Component.getLocation.

Stores the x,y origin of this component into "return value" rv and returns rv.

pack-priv static Set<KeyStroke>
getManagingFocusBackwardTraversalKeys()

Returns the Set of KeyStrokes to use if the component is managing focus for backward focus traversal.

pack-priv static Set<KeyStroke>
getManagingFocusForwardTraversalKeys()

Returns the Set of KeyStrokes to use if the component is managing focus for forward focus traversal.

public Dimension

Returns:

the value of the maximumSize property
getMaximumSize
()

Overrides java.awt.Container.getMaximumSize.

If the maximum size has been set to a non-null value just returns it.

public Dimension

Returns:

the value of the minimumSize property
getMinimumSize
()

Overrides java.awt.Container.getMinimumSize.

If the minimum size has been set to a non-null value just returns it.

public Component

Returns:

the Component that will follow this JComponent in the focus traversal cycle, or null if none has been explicitly specified
getNextFocusableComponent
()
Deprecated As of 1.4, replaced by FocusTraversalPolicy.

In release 1.4, the focus subsystem was rearchitected.

private int

Returns:

NOT_OBSCURED if non of the siblings above the Component obscure it, COMPLETELY_OBSCURED if one of the siblings completely obscures the Component or PARTIALLY_OBSCURED if the Component is only partially obscured.
getObscuredState
(int compIndex, int x, int y, int width, int height)

Returns whether or not the region of the specified component is obscured by a sibling.

public Point

Returns:

location to display the JPopupMenu, or null
getPopupLocation
(MouseEvent
the MouseEvent that triggered the popup to be shown, or null if the popup is not being shown as the result of a mouse event
event
)

Returns the preferred location to display the popup menu in this component's coordinate system.

public Dimension

Returns:

the value of the preferredSize property
getPreferredSize
()

Overrides java.awt.Container.getPreferredSize.

If the preferredSize has been set to a non-null value just returns it.

public KeyStroke[]

Returns:

an array of KeyStroke objects
getRegisteredKeyStrokes
()

Returns the KeyStrokes that will initiate registered actions.

public JRootPane

Returns:

the JRootPane that contains this component, or null if no JRootPane is found
getRootPane
()

Returns the JRootPane ancestor for this component.

public Dimension

Returns:

rv
getSize
(Dimension
the return value, modified to the component's size
rv
)

Overrides java.awt.Component.getSize.

Stores the width/height of this component into "return value" rv and returns rv.

public Point

Returns:

always returns null
getToolTipLocation
(MouseEvent
the MouseEvent that caused the ToolTipManager to show the tooltip
event
)

Returns the tooltip location in this component's coordinate system.

public String

Returns:

the text of the tool tip
getToolTipText
()

Returns the tooltip string that has been set with setToolTipText.

public String

Returns:

a string containing the tooltip
getToolTipText
(MouseEvent
the MouseEvent that initiated the ToolTip display
event
)

Returns the string to be used as the tooltip for event.

public Container

Returns:

the top-level Container that this component is in, or null if not in any container
getTopLevelAncestor
()

Returns the top-level ancestor of this component (the containing Window) or null if this component has not been added to any container.

public TransferHandler

Returns:

the value of the transferHandler property
getTransferHandler
()

Implements javax.swing.TransferHandler.HasGetTransferHandler.getTransferHandler.

Gets the transferHandler property.

public ComponentUI

Returns:

the ComponentUI object that renders this component
getUI
()

Returns the look and feel delegate that renders this component.

public String

Returns:

the UIDefaults key for a ComponentUI subclass
getUIClassID
()

Returns the UIDefaults key used to look up the name of the swing.plaf.ComponentUI class that defines the look and feel for this component.

public boolean

Returns:

value of the verifyInputWhenFocusTarget property
getVerifyInputWhenFocusTarget
()

Returns the value that indicates whether the input verifier for the current focus owner will be called before this component requests focus.

public synchronized VetoableChangeListener[]

Returns:

all of the component's VetoableChangeListeners or an empty array if no vetoable change listeners are currently registered
getVetoableChangeListeners
()

Returns an array of all the vetoable change listeners registered on this component.

public Rectangle

Returns:

the visible rectangle
getVisibleRect
()

Returns the Component's "visible rectangle" - the intersection of this component's visible rectangle, new Rectangle(0, 0, getWidth(), getHeight()), and all of its ancestors' visible rectangles.

public int

Returns:

the current width of this component
getWidth
()

Overrides java.awt.Component.getWidth.

Returns the current width of this component.

pack-priv static byte
public int

Returns:

the current x coordinate of the component's origin
getX
()

Overrides java.awt.Component.getX.

Returns the current x coordinate of the component's origin.

public int

Returns:

the current y coordinate of the component's origin
getY
()

Overrides java.awt.Component.getY.

Returns the current y coordinate of the component's origin.

public void
grabFocus()

Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.

public void
hide()

Overrides java.awt.Component.hide.

Deprecated

private static boolean
isComponentObtainingGraphicsFrom(Component c)

Returns true if c is the component the graphics is being requested of.

public boolean

Returns:

true if this component is double buffered, otherwise false
isDoubleBuffered
()

Overrides java.awt.Component.isDoubleBuffered.

Returns whether this component should use a buffer to paint.

public static boolean

Returns:

true if this component is lightweight
isLightweightComponent
(Component
the Component to be checked
c
)

Returns true if this component is lightweight, that is, if it doesn't have a native window system peer.

public boolean

Returns:

false
isManagingFocus
()
Deprecated As of 1.4, replaced by Component.setFocusTraversalKeys(int, Set) and Container.setFocusCycleRoot(boolean).

In release 1.4, the focus subsystem was rearchitected.

public boolean

Returns:

true if this component is completely opaque
isOpaque
()

Overrides java.awt.Component.isOpaque.

Returns true if this component is completely opaque.

public boolean

Returns:

always returns true
isOptimizedDrawingEnabled
()

Returns true if this component tiles its children -- that is, if it can guarantee that the children will not overlap.

pack-priv boolean
isPainting()

Returns true if this component, or any of its ancestors, are in the processing of painting.

public final boolean

Returns:

true if the current painting operation on this component is part of a print operation
isPaintingForPrint
()

Returns true if the current painting operation on this component is part of a print operation.

protected boolean

Returns:

always returns false
isPaintingOrigin
()

Returns true if a paint triggered on a child component should cause painting to originate from this Component, or one of its ancestors.

public boolean

Returns:

true if the component is currently painting a tile, false otherwise
isPaintingTile
()

Returns true if the component is currently painting a tile.

public boolean

Returns:

true if this component should get focus, otherwise returns false
isRequestFocusEnabled
()

Returns true if this JComponent should get focus; otherwise returns false.

public boolean

Returns:

always returns false
isValidateRoot
()

Overrides java.awt.Container.isValidateRoot.

If this method returns true, revalidate calls by descendants of this component will cause the entire tree beginning with this root to be validated.

public void
paint(Graphics
the Graphics context in which to paint
g
)

Overrides java.awt.Container.paint.

Invoked by Swing to draw components.

protected void
paintBorder(Graphics
the Graphics context in which to paint
g
)

Paints the component's border.

protected void
paintChildren(Graphics
the Graphics context in which to paint
g
)

Paints this component's children.

protected void
paintComponent(Graphics
the Graphics object to protect
g
)

Calls the UI delegate's paint method, if the UI delegate is non-null.

pack-priv void
public void
paintImmediately(int
the x value of the region to be painted
x
,
int
the y value of the region to be painted
y
,
int
the width of the region to be painted
w
,
int
the height of the region to be painted
h
)

Paints the specified region in this component and all of its descendants that overlap the region, immediately.

public void
paintImmediately(Rectangle
a Rectangle containing the region to be painted
r
)

Paints the specified region now.

pack-priv void
paintToOffscreen(Graphics g, int x, int y, int w, int h, int maxX, int maxY)

Paints to the specified graphics.

protected String

Returns:

a string representation of this JComponent
paramString
()

Overrides java.awt.Container.paramString.

Returns a string representation of this JComponent.

public void
printAll(Graphics
the Graphics context in which to paint
g
)

Overrides java.awt.Component.printAll.

Invoke this method to print the component.

protected void
printBorder(Graphics
the Graphics context in which to paint
g
)

Prints the component's border.

protected void
printChildren(Graphics
the Graphics context in which to paint
g
)

Prints this component's children.

protected void
printComponent(Graphics
the Graphics context in which to paint
g
)

This is invoked during a printing operation.

protected void
processComponentKeyEvent(KeyEvent
the event to be processed
e
)

Processes any key events that the component itself recognizes.

protected boolean

Returns:

true if there was a binding to an action, and the action was enabled
processKeyBinding
(KeyStroke
the KeyStroke queried
ks
,
KeyEvent
the KeyEvent
e
,
int
one of the following values:
  • JComponent.WHEN_FOCUSED
  • JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
  • JComponent.WHEN_IN_FOCUSED_WINDOW
condition
,
boolean
true if the key is pressed
pressed
)

Invoked to process the key bindings for ks as the result of the KeyEvent e.

pack-priv boolean

Returns:

true if there is a key binding for e
processKeyBindings
(KeyEvent
the unconsumed KeyEvent
e
,
boolean
true if the key is pressed
pressed
)

This is invoked as the result of a KeyEvent that was not consumed by the FocusManager, KeyListeners, or the component.

pack-priv static boolean
processKeyBindingsForAllComponents(KeyEvent e, Container container, boolean pressed)

protected void
processKeyEvent(KeyEvent e)

Overrides java.awt.Component.processKeyEvent.

Overrides processKeyEvent to process events.

protected void
processMouseEvent(MouseEvent
the mouse event
e
)

Overrides java.awt.Component.processMouseEvent.

Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects, refer to java.awt.Component#processMouseEvent(MouseEvent) for a complete description of this method.

protected void
processMouseMotionEvent(MouseEvent
the MouseEvent
e
)

Overrides java.awt.Component.processMouseMotionEvent.

Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.

public final void
putClientProperty(Object
the new client property key
key
,
Object
the new client property value; if null this method will remove the property
value
)

Adds an arbitrary key/value "client property" to this component.

private void
readObject(ObjectInputStream
the ObjectInputStream from which to read
s
)

Hides java.awt.Container.readObject.

We use the ObjectInputStream "registerValidation" callback to update the UI for the entire tree of components after they've all been read in.

pack-priv boolean

Returns:

true if the specified rectangle is obscured by an opaque child
rectangleIsObscured
(int
x value of specified rectangle
x
,
int
y value of specified rectangle
y
,
int
width of specified rectangle
width
,
int
height of specified rectangle
height
)

If the specified rectangle is completely obscured by any of this component's opaque children then returns true.

private static void
public void
registerKeyboardAction(ActionListener
the Action to be registered
anAction
,
String
the command to be set in the delivered event
aCommand
,
KeyStroke
the KeyStroke to bind to the action
aKeyStroke
,
int
the condition that needs to be met, see above
aCondition
)

This method is now obsolete, please use a combination of getActionMap() and getInputMap() for similar behavior.

public void
registerKeyboardAction(ActionListener
action to be registered to given keystroke and condition
anAction
,
KeyStroke
a KeyStroke
aKeyStroke
,
int
the condition to be associated with given keystroke and action
aCondition
)

This method is now obsolete, please use a combination of getActionMap() and getInputMap() for similar behavior.

private void
private void
registerNextFocusableComponent(Component nextFocusableComponent)

private void
registerWithKeyboardManager(boolean
if true, only actions that haven't been registered are pushed to the KeyboardManager
onlyIfNew
)

Registers any bound WHEN_IN_FOCUSED_WINDOW actions with the KeyboardManager.

private void
public void
removeAncestorListener(AncestorListener
the AncestorListener to be removed
listener
)

Unregisters listener so that it will no longer receive AncestorEvents.

public void
removeNotify()

Overrides java.awt.Container.removeNotify.

Notifies this component that it no longer has a parent component.

public synchronized void
removeVetoableChangeListener(VetoableChangeListener
the VetoableChangeListener to be removed
listener
)

Removes a VetoableChangeListener from the listener list.

public void
repaint(long
this parameter is not used
tm
,
int
the x value of the dirty region
x
,
int
the y value of the dirty region
y
,
int
the width of the dirty region
width
,
int
the height of the dirty region
height
)

Overrides java.awt.Component.repaint.

Adds the specified region to the dirty region list if the component is showing.

public void
repaint(Rectangle
a Rectangle containing the dirty region
r
)

Adds the specified region to the dirty region list if the component is showing.

public boolean

Returns:

true if this component can request to get the input focus, false if it can not
requestDefaultFocus
()
Deprecated As of 1.4, replaced by FocusTraversalPolicy.getDefaultComponent(Container).requestFocus()

In release 1.4, the focus subsystem was rearchitected.

public void
requestFocus()

Overrides java.awt.Component.requestFocus.

Requests that this Component gets the input focus.

public boolean

Returns:

false if the focus change request is guaranteed to fail; true if it is likely to succeed
requestFocus
(boolean
boolean indicating if the focus change is temporary
temporary
)

Overrides java.awt.Component.requestFocus.

Requests that this Component gets the input focus.

public boolean

Returns:

false if the focus change request is guaranteed to fail; true if it is likely to succeed
requestFocusInWindow
()

Overrides java.awt.Component.requestFocusInWindow.

Requests that this Component gets the input focus.

protected boolean

Returns:

false if the focus change request is guaranteed to fail; true if it is likely to succeed
requestFocusInWindow
(boolean
boolean indicating if the focus change is temporary
temporary
)

Overrides java.awt.Component.requestFocusInWindow.

Requests that this Component gets the input focus.

public void
resetKeyboardActions()

Unregisters all the bindings in the first tier InputMaps and ActionMap.

public void
reshape(int
the new horizontal location
x
,
int
the new vertical location
y
,
int
the new width
w
,
int
the new height
h
)

Overrides java.awt.Component.reshape.

Deprecated As of JDK 5, replaced by Component.setBounds(int, int, int, int).

Moves and resizes this component.

Reshapes the bounding rectangle for this component.

public void
revalidate()

Overrides java.awt.Component.revalidate.

Supports deferred automatic layout.

pack-priv static Graphics
pack-priv static Graphics
public void
scrollRectToVisible(Rectangle
the visible Rectangle
aRect
)

Forwards the scrollRectToVisible() message to the JComponent's parent.

public final void
setActionMap(ActionMap
the new ActionMap
am
)

Sets the ActionMap to am.

public void
setAlignmentX(float
the new horizontal alignment
alignmentX
)

Sets the horizontal alignment.

public void
setAlignmentY(float
the new vertical alignment
alignmentY
)

Sets the vertical alignment.

public void
setAutoscrolls(boolean
if true, synthetic mouse dragged events are generated when the mouse is dragged outside of a component's bounds and the mouse button continues to be held down; otherwise false
autoscrolls
)

Sets the autoscrolls property.

public void
setBackground(Color
the desired background Color
bg
)

Overrides java.awt.Component.setBackground.

Sets the background color of this component.

public void
setBorder(Border
the border to be rendered for this component
border
)

Sets the border of this component.

public void
setComponentPopupMenu(JPopupMenu
the popup that will be assigned to this component may be null
popup
)

Sets the JPopupMenu for this JComponent.

pack-priv void
setCreatedDoubleBuffer(boolean
true if the double buffer image was created from this component
newValue
)

This is invoked by the RepaintManager if createImage is called on the component.

public void
setDebugGraphicsOptions(int
determines how the component should display the information; one of the following options:
  • DebugGraphics.LOG_OPTION - causes a text message to be printed.
  • DebugGraphics.FLASH_OPTION - causes the drawing to flash several times.
  • DebugGraphics.BUFFERED_OPTION - creates an ExternalWindow that displays the operations performed on the View's offscreen buffer.
  • DebugGraphics.NONE_OPTION disables debugging.
  • A value of 0 causes no changes to the debugging options.
debugOptions is bitwise OR'd into the current value
debugOptions
)

Enables or disables diagnostic information about every graphics operation performed within the component or one of its children.

public static void
setDefaultLocale(Locale
the desired default Locale for new components.
l
)

Sets the default locale used to initialize each JComponent's locale property upon creation.

public void
setDoubleBuffered(boolean
if true, set this component to be double buffered
aFlag
)

Sets whether this component should use a buffer to paint.

pack-priv Object

Returns:

any saved state for this component, or null if none
setDropLocation
(TransferHandler.DropLocation
the drop location (as calculated by dropLocationForPoint) or null if there's no longer a valid drop location
location
,
Object
the state object saved earlier for this component, or null
state
,
boolean
whether or not the method is being called because an actual drop occurred
forDrop
)

Called to set or clear the drop location during a DnD operation.

public void
setEnabled(boolean
true if this component should be enabled, false otherwise
enabled
)

Overrides java.awt.Component.setEnabled.

Sets whether or not this component is enabled.

private void
setFlag(int aFlag, boolean aValue)

public void
setFocusTraversalKeys(int
one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, or KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
id
,
Set<? extends AWTKeyStroke>
the Set of AWTKeyStroke for the specified operation
keystrokes
)

Overrides java.awt.Container.setFocusTraversalKeys.

Sets the focus traversal keys for a given traversal operation for this Component.

public void
setFont(Font
the desired Font for this component
font
)

Overrides java.awt.Container.setFont.

Sets the font for this component.

public void
setForeground(Color
the desired foreground Color
fg
)

Overrides java.awt.Component.setForeground.

Sets the foreground color of this component.

public void
setInheritsPopupMenu(boolean
whether or not the JPopupMenu is inherited
value
)

Sets whether or not getComponentPopupMenu should delegate to the parent if this component does not have a JPopupMenu assigned to it.

public final void
setInputMap(int
one of the values listed above
condition
,
InputMap
the InputMap to use for the given condition
map
)

Sets the InputMap to use under the condition condition to map.

public void
setInputVerifier(InputVerifier
the new input verifier
inputVerifier
)

Sets the input verifier for this component.

public void
setMaximumSize(Dimension
a Dimension containing the desired maximum allowable size
maximumSize
)

Overrides java.awt.Component.setMaximumSize.

Sets the maximum size of this component to a constant value.

public void
setMinimumSize(Dimension
the new minimum size of this component
minimumSize
)

Overrides java.awt.Component.setMinimumSize.

Sets the minimum size of this component to a constant value.

public void
setNextFocusableComponent(Component
the Component that should follow this JComponent in the focus traversal cycle
aComponent
)
Deprecated As of 1.4, replaced by FocusTraversalPolicy

In release 1.4, the focus subsystem was rearchitected.

public void
setOpaque(boolean
true if this component should be opaque
isOpaque
)

If true the component paints every pixel within its bounds.

pack-priv void
setPaintingChild(Component paintingChild)

public void
setPreferredSize(Dimension preferredSize)

Overrides java.awt.Component.setPreferredSize.

Sets the preferred size of this component.

public void
setRequestFocusEnabled(boolean
indicates whether you want this JComponent to be focusable or not
requestFocusEnabled
)

Provides a hint as to whether or not this JComponent should get focus.

public void
setToolTipText(String
the string to display; if the text is null, the tool tip is turned off for this component
text
)

Registers the text to display in a tool tip.

public void
setTransferHandler(TransferHandler
the new TransferHandler
newHandler
)

Sets the TransferHandler, which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop.

protected void
setUI(ComponentUI
the new UI delegate
newUI
)

Sets the look and feel delegate for this component.

pack-priv void
setUIProperty(String propertyName, Object value)

public void
setVerifyInputWhenFocusTarget(boolean
value for the verifyInputWhenFocusTarget property
verifyInputWhenFocusTarget
)

Sets the value to indicate whether input verifier for the current focus owner will be called before this component requests focus.

public void
setVisible(boolean
true to make the component visible; false to make it invisible
aFlag
)

Overrides java.awt.Component.setVisible.

Makes the component visible or invisible.

pack-priv static void
setWriteObjCounter(JComponent comp, byte count)

pack-priv int
shouldDebugGraphics()

Returns true if debug information is enabled for this JComponent or one of its parents.

pack-priv void
private void
uninstallUIAndProperties()

Uninstalls the UI, if any, and any client properties designated as being specific to the installed UI - instances of UIClientPropertyKey.

public void
unregisterKeyboardAction(KeyStroke
the keystroke for which to unregister its keyboard action
aKeyStroke
)

This method is now obsolete.

private void
unregisterWithKeyboardManager()

Unregisters all the previously registered WHEN_IN_FOCUSED_WINDOW KeyStroke bindings.

private void
public void
update(Graphics
the Graphics context in which to paint
g
)

Overrides java.awt.Container.update.

Calls paint.

public void
updateUI()

This method is called to update the UI property to a value from the current look and feel.

private float
validateAlignment(float alignment)

private void
writeObject(ObjectOutputStream
the ObjectOutputStream in which to write
s
)

Hides java.awt.Container.writeObject.

Before writing a JComponent to an ObjectOutputStream we temporarily uninstall its UI.

Inherited from java.awt.Container:
addaddaddaddaddaddContainerListeneraddImpladdPropertyChangeListeneraddPropertyChangeListenerapplyComponentOrientationareFocusTraversalKeysSetcountComponentsdeliverEventdoLayoutfindComponentAtfindComponentAtgetComponentgetComponentAtgetComponentAtgetComponentCountgetComponentsgetComponentZOrdergetContainerListenersgetFocusTraversalKeysgetFocusTraversalPolicygetLayoutgetMousePositioninsetsinvalidateisAncestorOfisFocusCycleRootisFocusCycleRootisFocusTraversalPolicyProviderisFocusTraversalPolicySetlayoutlistlistlocateminimumSizepaintComponentspreferredSizeprintComponentsprocessContainerEventprocessEventremoveremoveremoveAllremoveContainerListenersetComponentZOrdersetFocusCycleRootsetFocusTraversalPolicysetFocusTraversalPolicyProvidersetLayouttransferFocusDownCyclevalidatevalidateTree