All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.JComponent
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
- public class JComponent
- extends Container
The base class for the Swing architecture that provides truly portable,
all-Java components with a "pluggable look and feel" (l&f) that can be
specified by the programmer or (optionally) selected by the user at runtime.
The JComponent architecure facilitates the handing of nested components.
JComponent objects allow you to register keyboard-initiated actions
that will occur whenever the component, one of its children, or one of
its parent containers has the focus, depending on the conditions specified
at registration.
- See Also:
- registerKeyboardAction
-
accessibleDescription
-
-
accessibleName
-
-
propertyTable
-
-
TOOL_TIP_TEXT_KEY
-
-
ui
-
-
UNDEFINED_CONDITION
- Constand used by some of the apis to mean that no condition is defined
-
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
- Constant used for registerKeyboardAction() which
means that the comand should be invoked when the receiving
component is an ancestor of the focused component or is
itself the focused component.
-
WHEN_FOCUSED
- Constant used for registerKeyboardAction() which
means that the command should be invoked when
the component has the focus.
-
WHEN_IN_FOCUSED_WINDOW
- Constant used for registerKeyboardAction() which
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.
-
JComponent()
-
-
JComponent(LayoutManager2)
-
-
addAccessibleSelection(int)
- Adds the nth selected item in the object to the object's
selection.
-
addAncestorListener(AncestorListener)
- Registers listener so that it will receive AncestorEvents
when it or any of its ancestors move or are made visible / invisible.
-
addNotify()
-
-
addPropertyChangeListener(PropertyChangeListener)
- Add a PropertyChangeListener to the listener list.
-
addVetoableChangeListener(VetoableChangeListener)
- Add a VetoableChangeListener to the listener list.
-
clearAccessibleSelection()
- Clears the selection in the object, so that nothing in the
object is selected.
-
computeVisibleRect(Rectangle)
- Returns the Component's "visible rect rectangle" - the
intersection of the visible rectangles for this component
and all of its ancestors.
-
createToolTip()
- Returns the instance of JToolTip that should be used to display the tooltip.
-
doAccessibleAction(int)
- Perform the nth Action on the object
-
firePropertyChange(String, Object, Object)
- Support for reporting bound property changes.
-
fireVetoableChange(String, Object, Object)
- Support for reporting constrained property changes.
-
getAccessibleActionCount()
- Returns the number of Actions available in this object
If there is more than one, the first one is the "default"
action (if any action is considered "default").
-
getAccessibleActionDescription(int)
- Return a description of the nth action of the object.
-
getAccessibleAt(Point)
- Returns the Accessible child contained at the local coordinate
Point, if one exists.
-
getAccessibleChild(int)
- Return the nth Accessible child of the object.
-
getAccessibleChildrenCount()
- Returns the number of accessible children in the object.
-
getAccessibleDescription()
- Get the accessible description of this object.
-
getAccessibleName()
- Get the accessible name of this object.
-
getAccessibleParent()
- Get the Accessible parent of this object.
-
getAccessibleRole()
- Get the role of this object.
-
getAccessibleSelection(int)
- Returns an Accessible representing the nth selected item
in the object.
-
getAccessibleSelectionCount()
- Returns the number of items currently selected.
-
getAccessibleStateSet()
- Get the state of this object.
-
getAccessibleText()
- Gets the AccessibleText interface for the component.
-
getAccessibleValue()
- Get the value of this object as a String.
-
getActionForKeyStroke(KeyStroke)
-
Return the object that will perform the action registered for a
given keystroke.
-
getAlignmentX()
-
-
getAlignmentY()
-
-
getAppropriateGraphics(Graphics)
-
-
getAutoscrolls()
-
-
getBounds(Rectangle)
-
Store the bounds of this component into "return value" rv and
return rv.
-
getClientProperties()
- Support for managing a small set of per-instance properties.
-
getClientProperty(Object)
- A convenience method for looking up a property value.
-
getConditionForKeyStroke(KeyStroke)
-
Return the condition that determines whether a registered action
occurs in response to the specified keystroke.
-
getDebugGraphicsOptions()
- Returns the state of graphics debugging.
-
getGraphics()
-
-
getHeight()
-
Return the current height of this component.
-
getInsets()
- If the insets has been set to a non-null value
just return it.
-
getLocation(Point)
- Store the x,y origin of this component into "return value" rv
and return rv.
-
getMaximumSize()
- If the maximumSize has been set to a non-null value
just return it.
-
getMinimumSize()
- If the minimumSize has been set to a non-null value
just return it.
-
getNextAccessibleSibling()
- Get the next sibling of this Accessible, if a preferred one exists.
-
getNextFocusableComponent()
-
Return the next focusable component or null if the focus manager
should choose the next focusable component automatically
-
getPreferredSize()
- If the preferredSize has been set to a non-null value
just return it.
-
getPreviousAccessibleSibling()
- Get the previous sibling of this Accessible, if a preferred one exists.
-
getRegisteredKeyStrokes()
-
Return the KeyStrokes that will initiate registered actions.
-
getSize(Dimension)
- Store the width/height of this component into "return value" rv
and return rv.
-
getToolTipText()
- Return the tooltip string that has been set with setToolTipText()
-
getToolTipText(MouseEvent)
- Returns the string to be used as the tooltip for event.
-
getVisibleRect()
- Returns the Component's "visible rectangle" - the
intersection of this components visible rectangle:
new Rectangle(0, 0, getSize.width(), getSize().height());
and all of its ancestors visible Rectangles.
-
getWidth()
-
Return the current width of this component.
-
getWindowAncestor()
- Returns the top-level window ancestor of this component, or null
if this component has not been added to any window.
-
getX()
-
Return the current x coordinate of the components origin.
-
getY()
-
Return the current y coordinate of the components origin.
-
hasFocus()
- Returns true if this Component has the keyboard focus.
-
isFocusCycleRoot()
- Override this method and return true if your component is the root of
of a component tree with its own focus cycle.
-
isFocusTraversable()
-
-
isLightweightComponent(Component)
- Returns true if this component is a lightweight, i.e.
-
isManagingFocus()
- Override this method and return true if your JComponent manages focus.
-
isOpaque()
- Returns true if this component is completely opaque.
-
isOptimizedDrawingEnabled()
- Returns true if this component tiles its children, i.e.
-
paint(Graphics)
-
-
paintImmediately(int, int, int, int)
-
Paint the specified region in this component and all of its
descendants that overlap the region, immediately
It's rarely neccessary to call this method.
-
paintImmediately(Rectangle)
-
Paint the specified region now.
-
processKeyEvent(KeyEvent)
- Override processKeyEvent to process events
-
processMouseMotionEvent(MouseEvent)
-
-
putClientProperty(Object, Object)
- A convenience method for storing up a property value.
-
registerKeyboardAction(ActionListener, KeyStroke, int)
- Register a new keyboard action.
-
removeAccessibleSelection(int)
- Removes the nth selected item in the object from the object's
selection.
-
removeAncestorListener(AncestorListener)
- Unregisters listener so that it will no longer receive
AncestorEvents
This method will migrate to java.awt.Component in the next major JDK release
-
removeNotify()
-
-
removePropertyChangeListener(PropertyChangeListener)
- Remove a PropertyChangeListener from the listener list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Remove a VetoableChangeListener from the listener list.
-
repaint(long, int, int, int, int)
- Adds the specified region to the dirty region list.
-
repaint(Rectangle)
- Adds the specified region to the dirty region list.
-
requestDefaultFocus()
- Request the focus for the component that should have the focus
by default.
-
resetKeyboardActions()
-
Unregister all keyboard actions
-
scrollRectToVisible(Rectangle)
- Forwards the scrollRectToVisible() message to the JComponent's
parent.
-
selectAllAccessibleSelection()
- Causes every selected item in the object to be selected,
if the object supports multiple selections (if getAccessibleStateSet
returns a state that is MULTISELECTABLE).
-
setAccessibleDescription(String)
- Set the accessible description of this object.
-
setAccessibleName(String)
- Set the localized accessible name of this object.
-
setAlignmentX(float)
- Set the value of the alignmentX property.
-
setAlignmentY(float)
- Set the value of the alignmentY property.
-
setAutoscrolls(boolean)
- If true this component will automatically scroll it contents when
dragged, if contained in a component that supports scrolling, such as
JViewport
-
setBounds(int, int, int, int)
-
Moves and resizes this component.
-
setBounds(Rectangle)
-
Moves and resizes this component.
-
setClientProperties(Dictionary)
- Replace the client properties dictionary for this component.
-
setDebugGraphicsOptions(int)
- Enables or disables diagnostic information about every graphics
operation performed within the JComponent or one of its children.
-
setInsets(Insets)
- Sets the insets of this component to a constant
value.
-
setMaximumSize(Dimension)
- Sets the maximumSize of this component to a constant
value.
-
setMinimumSize(Dimension)
- Sets the minimumSize of this component to a constant
value.
-
setNextFocusableComponent(Component)
-
-
setPreferredSize(Dimension)
- Set the preferred size of the receiving component.
-
setToolTipText(String)
- Registers text as the string to be displayed in a ToolTip.
-
setUI(ComponentUI)
-
-
unregisterKeyboardAction(KeyStroke)
-
Unregister a keyboard action.
-
updateUI()
- Notification from the UIFactory that the L&F
has changed.
ui
protected ComponentUI ui
propertyTable
protected Object propertyTable[]
WHEN_FOCUSED
public static final int WHEN_FOCUSED
- Constant used for registerKeyboardAction() which
means that the command should be invoked when
the component has the focus.
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
- Constant used for registerKeyboardAction() which
means that the comand should be invoked when the receiving
component is an ancestor of the focused component or is
itself the focused component.
WHEN_IN_FOCUSED_WINDOW
public static final int WHEN_IN_FOCUSED_WINDOW
- Constant used for registerKeyboardAction() which
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.
UNDEFINED_CONDITION
public static final int UNDEFINED_CONDITION
- Constand used by some of the apis to mean that no condition is defined
TOOL_TIP_TEXT_KEY
public static final String TOOL_TIP_TEXT_KEY
accessibleName
protected String accessibleName
accessibleDescription
protected String accessibleDescription
JComponent
public JComponent()
JComponent
public JComponent(LayoutManager2 layout)
updateUI
public void updateUI()
- Notification from the UIFactory that the L&F
has changed. An example implementation of this
for JButton might be:
public void updateUI() {
setUI((ButtonUI)UIManager.getUI(
"ButtonUI", "com.sun.java.swing.basic.BasicButton", this));
invalidate();
}
setUI
protected void setUI(ComponentUI x)
getAppropriateGraphics
protected Graphics getAppropriateGraphics(Graphics g)
paint
public void paint(Graphics g)
- Overrides:
- paint in class Container
isFocusCycleRoot
public boolean isFocusCycleRoot()
- Override this method and return true if your component is the root of
of a component tree with its own focus cycle.
isManagingFocus
public boolean isManagingFocus()
- Override this method and return true if your JComponent manages focus.
If your component manages focus, the focus manager will handle your
component's children. All key event will be sent to your key listener
including TAB and SHIFT+TAB. CONTROL + TAB and CONTROL + SHIFT + TAB
will move the focus to the next / previous component.
setNextFocusableComponent
public void setNextFocusableComponent(Component aComponent)
getNextFocusableComponent
public Component getNextFocusableComponent()
- Return the next focusable component or null if the focus manager
should choose the next focusable component automatically
setPreferredSize
public void setPreferredSize(Dimension preferredSize)
- Set the preferred size of the receiving component.
if
preferredSize
is null, the UI will
be asked for the preferred size
getPreferredSize
public Dimension getPreferredSize()
- If the preferredSize has been set to a non-null value
just return it. If the UI delegates getPreferredSize()
method returns a non null then value return that, otherwise
defer to the components layout manager.
- Returns:
- the value of the preferredSize property.
- Overrides:
- getPreferredSize in class Container
- See Also:
- setPreferredSize
setMaximumSize
public void setMaximumSize(Dimension maximumSize)
- Sets the maximumSize of this component to a constant
value. Subsequent calls to getMaximumSize will always
return this value, the components UI will not be asked
to compute it. Setting the maximumSize to null
restores the default behavior.
- See Also:
- getMaximumSize
getMaximumSize
public Dimension getMaximumSize()
- If the maximumSize has been set to a non-null value
just return it. If the UI delegates getMaximumSize()
method returns a non null value then return that, otherwise
defer to the components layout manager.
- Returns:
- the value of the maximumSize property.
- Overrides:
- getMaximumSize in class Container
- See Also:
- setMaximumSize
setMinimumSize
public void setMinimumSize(Dimension minimumSize)
- Sets the minimumSize of this component to a constant
value. Subsequent calls to getMinimumSize will always
return this value, the components UI will not be asked
to compute it. Setting the minimumSize to null
restores the default behavior.
- See Also:
- getMinimumSize
getMinimumSize
public Dimension getMinimumSize()
- If the minimumSize has been set to a non-null value
just return it. If the UI delegates getMinimumSize()
method returns a non null value then return that, otherwise
defer to the components layout manager.
- Returns:
- the value of the minimumSize property.
- Overrides:
- getMinimumSize in class Container
- See Also:
- setMinimumSize
setInsets
public void setInsets(Insets insets)
- Sets the insets of this component to a constant
value. Subsequent calls to getMinimumSize will always
return this value, the components UI will not be asked
to compute it. Setting the insets to null
restores the default behavior.
- See Also:
- getInsets
getInsets
public Insets getInsets()
- If the insets has been set to a non-null value
just return it. If the UI delegates getMinimumSize()
method returns a non null value then return that, otherwise
defer to the components layout manager.
- Returns:
- the value of the insets property.
- Overrides:
- getInsets in class Container
- See Also:
- setInsets
getAlignmentY
public float getAlignmentY()
- Returns:
- the value of the alignmentY property.
- Overrides:
- getAlignmentY in class Container
- See Also:
- setAlignmentY, getAlignmentY
setAlignmentY
public void setAlignmentY(float alignmentY)
- Set the value of the alignmentY property.
- See Also:
- getAlignmentY
getAlignmentX
public float getAlignmentX()
- Returns:
- the value of the alignmentX property.
- Overrides:
- getAlignmentX in class Container
- See Also:
- setAlignmentX, getAlignmentX
setAlignmentX
public void setAlignmentX(float alignmentX)
- Set the value of the alignmentX property.
- See Also:
- getAlignmentX
getGraphics
public Graphics getGraphics()
- Overrides:
- getGraphics in class Component
setDebugGraphicsOptions
public void setDebugGraphicsOptions(int debugOptions)
- Enables or disables diagnostic information about every graphics
operation performed within the JComponent or one of its children. The
value of debugOptions determines how the JComponent should
display this information:
- 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.
debug is bitwise OR'd into the current value.
DebugGraphics.NONE_OPTION disables debugging.
A value of 0 causes no changes to the debugging options.
getDebugGraphicsOptions
public int getDebugGraphicsOptions()
- Returns the state of graphics debugging.
- See Also:
- setDebugGraphicsOptions
registerKeyboardAction
public void registerKeyboardAction(ActionListener anAction,
KeyStroke aKeyStroke,
int aCondition)
- Register a new keyboard action.
anAction will be invoked if a key event matching aKeyStroke occurs
and aCondition is verified. The KeyStroke object defines a
particular combination of a keyboard key and one or more modifiers
(alt, shift, ctrl, meta).
aCondition can be one of:
- WHEN_FOCUSED
- The action will be invoked only when the keystroke occurs
while the JComponent has the focus.
- WHEN_IN_FOCUSED_WINDOW
- The action will be invoked when the keystroke occurs while
the JComponent has the focus or if the JComponent is in the
window that has the focus.
- WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
- The action will be invoked when the keystroke occurs while the
JComponent has the focus or if the JComponent is an ancestor of
the JComponent that has the focus.
The combination of keystrokes and conditions lets you define high
level (semantic) action events for a specified keystroke+modifier
combination (using the KeyStroke class) and direct to a parent or
child of a component that has the focus, or to the component itself.
In other words, in any hierarchical structure of components, an
arbitrary key-combination can be immediately directed to the
appropriate component in the hierarchy, and cause a specific method
to be invoked (usually by way of adapter objects).
If an action has already been registered for the receiving
container, with the same charCode and the same modifiers,
anAction will replace the action.
- See Also:
- KeyStroke
unregisterKeyboardAction
public void unregisterKeyboardAction(KeyStroke aKeyStroke)
- Unregister a keyboard action.
- See Also:
- registerKeyboardAction
getRegisteredKeyStrokes
public KeyStroke[] getRegisteredKeyStrokes()
- Return the KeyStrokes that will initiate registered actions.
- Returns:
- an array of KeyStroke objects
- See Also:
- registerKeyboardAction
getConditionForKeyStroke
public int getConditionForKeyStroke(KeyStroke aKeyStroke)
- Return the condition that determines whether a registered action
occurs in response to the specified keystroke.
- Returns:
- the action-keystroke condition
- See Also:
- registerKeyboardAction
getActionForKeyStroke
public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke)
- Return the object that will perform the action registered for a
given keystroke.
- Returns:
- the ActionListener object invoked when the keystroke occurs
- See Also:
- registerKeyboardAction
resetKeyboardActions
public void resetKeyboardActions()
- Unregister all keyboard actions
- See Also:
- registerKeyboardAction
requestDefaultFocus
public boolean requestDefaultFocus()
- Request the focus for the component that should have the focus
by default. The default implementation will request the focus
one the first component that is focus traversable recursively.
Return false if the focus has not been set
Return true otherwise.
isFocusTraversable
public boolean isFocusTraversable()
- Overrides:
- isFocusTraversable in class Component
processKeyEvent
protected void processKeyEvent(KeyEvent e)
- Override processKeyEvent to process events
- Overrides:
- processKeyEvent in class Component
setToolTipText
public void setToolTipText(String text)
- Registers text as the string to be displayed in a ToolTip.
getToolTipText
public String getToolTipText()
- Return the tooltip string that has been set with setToolTipText()
getToolTipText
public String getToolTipText(MouseEvent event)
- Returns the string to be used as the tooltip for event. By default
this returns any string set using setToolTipText(). If a component provides
more extensize API to support differing tooltips at different locations,
this method should be overridden.
createToolTip
public JToolTip createToolTip()
- Returns the instance of JToolTip that should be used to display the tooltip.
Components typically would not override this method, but it can be used to
cause different tooltips to be displayed differently.
scrollRectToVisible
public void scrollRectToVisible(Rectangle aRect)
- Forwards the scrollRectToVisible() message to the JComponent's
parent. Components that can service the request, such as a JViewport,
override this method and perform the scrolling.
- See Also:
- JViewport
setAutoscrolls
public void setAutoscrolls(boolean autoscrolls)
- If true this component will automatically scroll it contents when
dragged, if contained in a component that supports scrolling, such as
JViewport
- See Also:
- JViewport, getAutoscrolls
getAutoscrolls
public boolean getAutoscrolls()
processMouseMotionEvent
protected void processMouseMotionEvent(MouseEvent e)
- Overrides:
- processMouseMotionEvent in class Component
getNextAccessibleSibling
public Accessible getNextAccessibleSibling()
- Get the next sibling of this Accessible, if a preferred one exists.
This should generally return the next item in the tab order, if
that item implements Accessible
- Returns:
- the next Accessible, if there is one
getPreviousAccessibleSibling
public Accessible getPreviousAccessibleSibling()
- Get the previous sibling of this Accessible, if a preferred one exists.
This should generally return the previous item in the tab order, if
that item implements Accessible
- Returns:
- the previous Accessible, if there is one
getAccessibleAt
public Accessible getAccessibleAt(Point p)
- Returns the Accessible child contained at the local coordinate
Point, if one exists.
- Returns:
- the Accessible at the specified location, if it exists
getAccessibleName
public String getAccessibleName()
- Get the accessible name of this object. This should almost never
return java.awt.Component.getName(), as that generally isn't
a localized name, and doesn't have meaning for the user. If the
object is fundamentally a text object (e.g. a menu item), the
accessible name should be the text of the object (e.g. "save").
If the object has a tooltip, the tooltip text may also be an
appropriate String to return.
- Returns:
- the localized name of the object -- can be null if this
object does not have a name
- See Also:
- setAccessibleName
setAccessibleName
public void setAccessibleName(String s)
- Set the localized accessible name of this object.
- Parameters:
- s - the new localized name of the object.
- See Also:
- getAccessibleName
getAccessibleDescription
public String getAccessibleDescription()
- Get the accessible description of this object. This should be
a concise, localized description of what this object is - what
is it's meaning to the user. If the object has a tooltip, the
tooltip text may be an appropriate string to return, assuming
it contains a concise description of the object (instead of just
the name of the object - e.g. a "Save" icon on a toolbar that
had "save" as the tooltip text shouldn't return the tooltip
text as the description, but something like "Saves the current
text document" instead).
- Returns:
- the localized description of the object -- can be null if
this object does not have a description
- See Also:
- setAccessibleDescription
setAccessibleDescription
public void setAccessibleDescription(String s)
- Set the accessible description of this object.
- Parameters:
- s - the new localized description of the object
- See Also:
- getAccessibleDescription
getAccessibleStateSet
public AccessibleStateSet getAccessibleStateSet()
- Get the state of this object.
- Returns:
- an instance of AccessibleStateSet containing the current state
set of the object
- See Also:
- AccessibleState
getAccessibleRole
public AccessibleRole getAccessibleRole()
- Get the role of this object.
- Returns:
- an instance of AccessibleRole describing the role of the object
- See Also:
- AccessibleRole
getAccessibleValue
public String getAccessibleValue()
- Get the value of this object as a String. This should almost
never return java.Object.toString(), as that is not a localized,
human readable representation of the value of the object.
- Returns:
- human readable value of the object -- can be null if this
object does not have a value
getAccessibleParent
public Accessible getAccessibleParent()
- Get the Accessible parent of this object. If the parent of this
object implements Accessible, this method should simply return
getParent().
- Returns:
- the Accessible parent of this object -- can be null if this
object does not have an Accessible parent
getAccessibleChildrenCount
public int getAccessibleChildrenCount()
- Returns the number of accessible children in the object. If all
of the children of this object implement Accessible, than this
method should return the number of children of this object.
- Returns:
- the number of accessible children in the object.
getAccessibleChild
public Accessible getAccessibleChild(int i)
- Return the nth Accessible child of the object.
- Parameters:
- i - zero-based index of child
- Returns:
- the nth Accessible child of the object
getAccessibleActionCount
public int getAccessibleActionCount()
- Returns the number of Actions available in this object
If there is more than one, the first one is the "default"
action (if any action is considered "default").
- Returns:
- the number of Actions in this object
getAccessibleActionDescription
public String getAccessibleActionDescription(int i)
- Return a description of the nth action of the object.
This description should be human-readable; by default
it currently isn't...
- Parameters:
- i - zero-based index of the actions
- Returns:
- a description of the nth action
doAccessibleAction
public boolean doAccessibleAction(int i)
- Perform the nth Action on the object
- Parameters:
- i - zero-based index of actions
- Returns:
- whether the action was performed or not.
getAccessibleText
public AccessibleText getAccessibleText()
- Gets the AccessibleText interface for the component. If the component
does not speak AccessibleText, or have a proxy which does, this
method returns null.
- Returns:
- the AccessibleText of the object.
- See Also:
- AccessibleText
getAccessibleSelectionCount
public int getAccessibleSelectionCount()
- Returns the number of items currently selected.
If no items are selected, the return value will be 0.
- Returns:
- the number of items currently selected.
getAccessibleSelection
public Accessible getAccessibleSelection(int i)
- Returns an Accessible representing the nth selected item
in the object. If there isn't a selection, or there are
fewer items selcted than the integer passed in, the return
value will be null.
- Parameters:
- i - the zero-based index of selected items
- Returns:
- an Accessible containing the selected item
addAccessibleSelection
public void addAccessibleSelection(int i)
- Adds the nth selected item in the object to the object's
selection. If the object supports multiple selections,
(the method getAccessibleStateSet returns a state that is MULTISELECTABLE)
the nth item is added to any existing selection, otherwse
it replaces any existing selection in the objct. If the
nth item is already selected, this method has no effect.
- Parameters:
- i - the zero-based index of selectable items
- See Also:
- getAccessibleStateSet
removeAccessibleSelection
public void removeAccessibleSelection(int i)
- Removes the nth selected item in the object from the object's
selection. If the nth item isn't currently selected, this
method has no effect.
- Parameters:
- i - the zero-based index of selectable items
clearAccessibleSelection
public void clearAccessibleSelection()
- Clears the selection in the object, so that nothing in the
object is selected.
selectAllAccessibleSelection
public void selectAllAccessibleSelection()
- Causes every selected item in the object to be selected,
if the object supports multiple selections (if getAccessibleStateSet
returns a state that is MULTISELECTABLE).
- See Also:
- getAccessibleStateSet
getClientProperties
public Dictionary getClientProperties()
- Support for managing a small set of per-instance properties. Callers
can use the clientProperties dictionary to annotate components
that were created by another module, e.g. a layout manager might
store per child constraints this way. For example:
componentA.getClientProperties().put("to the left of", componentB);
The clientProperties dictionary is not intended to support large
scale extensions to JComponent nor should be it considered an
alternative to subclassing when designing a new component.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- a non null Dictionary
- See Also:
- setClientProperties
setClientProperties
public void setClientProperties(Dictionary x)
- Replace the client properties dictionary for this component.
This method will migrate to java.awt.Component in the next major JDK release
- See Also:
- getClientProperties
getClientProperty
public final Object getClientProperty(Object key)
- A convenience method for looking up a property value. It is
equivalent to:
getClientProperties().get(key);
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the value of this property or null
- See Also:
- getClientProperties
putClientProperty
public final void putClientProperty(Object key,
Object value)
- A convenience method for storing up a property value. It is
equivalent to:
getClientProperties().put(key, value);
If value is null this method does nothing.
This method will migrate to java.awt.Component in the next major JDK release
- See Also:
- getClientProperties
isLightweightComponent
public static boolean isLightweightComponent(Component c)
- Returns true if this component is a lightweight, i.e. if it doesn't
have a native window system peer.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- true if this component is a lightweight
setBounds
public void setBounds(int x,
int y,
int w,
int h)
- Moves and resizes this component.
- Overrides:
- setBounds in class Component
- See Also:
- setBounds
setBounds
public void setBounds(Rectangle r)
- Moves and resizes this component.
- Overrides:
- setBounds in class Component
- See Also:
- setBounds
getBounds
public Rectangle getBounds(Rectangle rv)
- Store the bounds of this component into "return value" rv and
return rv. This version of getBounds() is useful if the caller
wants to avoid allocating a new Rectangle object on the heap.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- rv - the return value, modified to the components bounds
- Returns:
- rv
getSize
public Dimension getSize(Dimension rv)
- Store the width/height of this component into "return value" rv
and return rv. This version of getSize() is useful if the
caller wants to avoid allocating a new Dimension object on the heap.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- rv - the return value, modified to the components size
- Returns:
- rv
getLocation
public Point getLocation(Point rv)
- Store the x,y origin of this component into "return value" rv
and return rv. This version of getLocation() is useful if the
caller wants to avoid allocating a new Point object on the heap.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- rv - the return value, modified to the components location
- Returns:
- rv
getX
public int getX()
- Return the current x coordinate of the components origin.
This method is preferable to writing component.getBounds().x,
or component.getLocation().x because it doesn't cause any
heap allocations.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the current x coordinate of the components origin.
getY
public int getY()
- Return the current y coordinate of the components origin.
This method is preferable to writing component.getBounds().y,
or component.getLocation().y because it doesn't cause any
heap allocations.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the current y coordinate of the components origin.
getWidth
public int getWidth()
- Return the current width of this component.
This method is preferable to writing component.getBounds().width,
or component.getSize().width because it doesn't cause any
heap allocations.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the current width of this component.
getHeight
public int getHeight()
- Return the current height of this component.
This method is preferable to writing component.getBounds().height,
or component.getSize().height because it doesn't cause any
heap allocations.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the current height of this component.
hasFocus
public boolean hasFocus()
- Returns true if this Component has the keyboard focus.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- true if this Component has the keyboard focus.
isOpaque
public boolean isOpaque()
- Returns true if this component is completely opaque. Subclasses
that guarantee to always completely paint their contents should
override this method and return true.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- true if this component is completely opaque.
computeVisibleRect
public void computeVisibleRect(Rectangle visibleRect)
- Returns the Component's "visible rect rectangle" - the
intersection of the visible rectangles for this component
and all of its ancestors. The return value is stored in
visibleRect
This method will migrate to java.awt.Component in the next major JDK release
- See Also:
- getVisibleRect
getVisibleRect
public Rectangle getVisibleRect()
- Returns the Component's "visible rectangle" - the
intersection of this components visible rectangle:
new Rectangle(0, 0, getSize.width(), getSize().height());
and all of its ancestors visible Rectangles.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the visible rectangle
firePropertyChange
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
- Support for reporting bound property changes. This method can be called
when a bound property has changed and it will send the appropriate
PropertyChangeEvent to any registered PropertyChangeListeners.
This method will migrate to java.awt.Component in the next major JDK release
addPropertyChangeListener
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
- Add a PropertyChangeListener to the listener list.
The listener is registered for all properties.
A PropertyChangeEvent will get fired in response to setting
a bound property, e.g. setFont, setBackground, or setForeground.
Note that if the current component is inheriting its foreground,
background, or font from its container, then no event will be
fired in response to a change in the inherited property.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- listener - The PropertyChangeListener to be added
removePropertyChangeListener
public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
- Remove a PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- listener - The PropertyChangeListener to be removed
fireVetoableChange
protected void fireVetoableChange(String propertyName,
Object oldValue,
Object newValue) throws PropertyVetoException
- Support for reporting constrained property changes. This method can be called
when a constrained property has changed and it will send the appropriate
PropertyChangeEvent to any registered VetoableChangeListeners.
This method will migrate to java.awt.Component in the next major JDK release
- Throws: PropertyVetoException
- when the attempt to set the property is vetoed
by the receiver.
addVetoableChangeListener
public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
- Add a VetoableChangeListener to the listener list.
The listener is registered for all properties.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- listener - The VetoableChangeListener to be added
removeVetoableChangeListener
public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
- Remove a VetoableChangeListener from the listener list.
This removes a VetoableChangeListener that was registered
for all properties.
This method will migrate to java.awt.Component in the next major JDK release
- Parameters:
- listener - The VetoableChangeListener to be removed
getWindowAncestor
public Window getWindowAncestor()
- Returns the top-level window ancestor of this component, or null
if this component has not been added to any window.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- the top-level window which this component is in.
addAncestorListener
public void addAncestorListener(AncestorListener listener)
- Registers listener so that it will receive AncestorEvents
when it or any of its ancestors move or are made visible / invisible.
Events are also sent when the component or its ancestors are added
or removed from the Component hierarchy
This method will migrate to java.awt.Component in the next major JDK release
- See Also:
- AncestorEvent
removeAncestorListener
public void removeAncestorListener(AncestorListener listener)
- Unregisters listener so that it will no longer receive
AncestorEvents
This method will migrate to java.awt.Component in the next major JDK release
- See Also:
- addAncestorListener
addNotify
public void addNotify()
- Overrides:
- addNotify in class Container
removeNotify
public void removeNotify()
- Overrides:
- removeNotify in class Container
repaint
public void repaint(long tm,
int x,
int y,
int width,
int height)
- Adds the specified region to the dirty region list. The component
will be repainted after all of the currently pending events have
been dispatched.
- Overrides:
- repaint in class Component
- See Also:
- DirtyRegionRegionManager
repaint
public void repaint(Rectangle r)
- Adds the specified region to the dirty region list. The component
will be repainted after all of the currently pending events have
been dispatched.
- See Also:
- DirtyRegionRegionManager
isOptimizedDrawingEnabled
public boolean isOptimizedDrawingEnabled()
- Returns true if this component tiles its children, i.e. if
it can guarantee that the children will not overlap. The
repainting system is substantially more efficient in this
common case. JComponent subclasses that can't make this
guarantee, e.g. JLayeredPane, should override this method
to return false.
This method will migrate to java.awt.Component in the next major JDK release
- Returns:
- true if this components children don't overlap
paintImmediately
public void paintImmediately(int x,
int y,
int w,
int h)
- Paint the specified region in this component and all of its
descendants that overlap the region, immediately
It's rarely neccessary to call this method. In most cases it's
more efficient to call repaint which defers the actual painting
and can collapse redundant requests into a single paint call.
This method is useful if one needs to update the display while
the current event is being dispatched.
This method will migrate to java.awt.Component in the next major JDK release
- See Also:
- repaint
paintImmediately
public void paintImmediately(Rectangle r)
- Paint the specified region now.
This method will migrate to java.awt.Component in the next major JDK release
All Packages Class Hierarchy This Package Previous Next Index