Class Container
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, MenuContainer, java.io.Serializable
- Direct Known Subclasses:
- Panel, ScrollPane, Window
public class Container extends ComponentA generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT components.Components added to a container are tracked in a list. The order of the list will define the components' front-to-back stacking order within the container. If no index is specified when adding a component to a container, it will be added to the end of the list (and hence to the bottom of the stacking order).
Note: For details on the focus subsystem, see How to Use the Focus Subsystem, a section in The Java Tutorial, and the Focus Specification for more information.
- Since:
- JDK1.0
- See Also:
add(java.awt.Component, int)
,getComponent(int)
,LayoutManager
, Serialized Form
-
-
Nested Classes Modifier and Type Class and Description AccessibleAWTComponent protected class
AccessibleAWTComponentInner class of Component used to provide default support for accessibility.protected class
AccessibleAWTComponent-
Inner class of Component used to provide default support for accessibility. This class is not meant to be used directly by application developers, but is instead meant only to be subclassed by component developers.
The class used to obtain the accessible role for this object.
- Since:
- 1.3
- See Also:
- Serialized Form
BaselineResizeBehavior static class
BaselineResizeBehaviorEnumeration of the common ways the baseline of a component can change as the size changes.static class
BaselineResizeBehavior-
Enumeration of the common ways the baseline of a component can change as the size changes. The baseline resize behavior is primarily for layout managers that need to know how the position of the baseline changes as the component size changes. In general the baseline resize behavior will be valid for sizes greater than or equal to the minimum size (the actual minimum size; not a developer specified minimum size). For sizes smaller than the minimum size the baseline may change in a way other than the baseline resize behavior indicates. Similarly, as the size approaches
Integer.MAX_VALUE
and/orShort.MAX_VALUE
the baseline may change in a way other than the baseline resize behavior indicates.- Since:
- 1.6
- See Also:
Component.getBaselineResizeBehavior()
,Component.getBaseline(int,int)
BltBufferStrategy protected class
BltBufferStrategyInner class for blitting offscreen surfaces to a component.protected class
BltBufferStrategy-
Inner class for blitting offscreen surfaces to a component.
- Since:
- 1.4
FlipBufferStrategy protected class
FlipBufferStrategyInner class for flipping buffers on a component.protected class
FlipBufferStrategyAccessibleAWTContainer protected class
AccessibleAWTContainerInner class of Container used to provide default support for accessibility.protected class
AccessibleAWTContainer-
Inner class of Container used to provide default support for accessibility. This class is not meant to be used directly by application developers, but is instead meant only to be subclassed by container developers.
The class used to obtain the accessible role for this object, as well as implementing many of the methods in the AccessibleContainer interface.
- Since:
- 1.3
- See Also:
- Serialized Form
-
-
Fields Modifier and Type Field and Description ABORT static int
ABORTThis flag in the infoflags argument to imageUpdate indicates that an image which was being tracked asynchronously was aborted before production was complete.public static final int ABORT-
This flag in the infoflags argument to imageUpdate indicates that an image which was being tracked asynchronously was aborted before production was complete. No more information will become available without further action to trigger another image production sequence. If the ERROR flag was not also set in this image update, then accessing any of the data in the image will restart the production again, probably from the beginning.
- See Also:
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
ALLBITS static int
ALLBITSThis flag in the infoflags argument to imageUpdate indicates that a static image which was previously drawn is now complete and can be drawn again in its final form.public static final int ALLBITS-
This flag in the infoflags argument to imageUpdate indicates that a static image which was previously drawn is now complete and can be drawn again in its final form. The x, y, width, and height arguments to the imageUpdate callback method should be ignored.
- See Also:
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
BOTTOM_ALIGNMENT static float
BOTTOM_ALIGNMENTEase-of-use constant forgetAlignmentY
.public static final float BOTTOM_ALIGNMENT-
Ease-of-use constant for
getAlignmentY
. Specifies an alignment to the bottom of the component.
CENTER_ALIGNMENT static float
CENTER_ALIGNMENTEase-of-use constant forgetAlignmentY
andgetAlignmentX
.public static final float CENTER_ALIGNMENT-
Ease-of-use constant for
getAlignmentY
andgetAlignmentX
. Specifies an alignment to the center of the component
ERROR static int
ERRORThis flag in the infoflags argument to imageUpdate indicates that an image which was being tracked asynchronously has encountered an error.public static final int ERROR-
This flag in the infoflags argument to imageUpdate indicates that an image which was being tracked asynchronously has encountered an error. No further information will become available and drawing the image will fail. As a convenience, the ABORT flag will be indicated at the same time to indicate that the image production was aborted.
- See Also:
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
FRAMEBITS static int
FRAMEBITSThis flag in the infoflags argument to imageUpdate indicates that another complete frame of a multi-frame image which was previously drawn is now available to be drawn again.public static final int FRAMEBITS-
This flag in the infoflags argument to imageUpdate indicates that another complete frame of a multi-frame image which was previously drawn is now available to be drawn again. The x, y, width, and height arguments to the imageUpdate callback method should be ignored.
- See Also:
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
HEIGHT static int
HEIGHTThis flag in the infoflags argument to imageUpdate indicates that the height of the base image is now available and can be taken from the height argument to the imageUpdate callback method.public static final int HEIGHT-
This flag in the infoflags argument to imageUpdate indicates that the height of the base image is now available and can be taken from the height argument to the imageUpdate callback method.
- See Also:
Image.getHeight(java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
LEFT_ALIGNMENT static float
LEFT_ALIGNMENTEase-of-use constant forgetAlignmentX
.public static final float LEFT_ALIGNMENT-
Ease-of-use constant for
getAlignmentX
. Specifies an alignment to the left side of the component.
PROPERTIES static int
PROPERTIESThis flag in the infoflags argument to imageUpdate indicates that the properties of the image are now available.public static final int PROPERTIES-
This flag in the infoflags argument to imageUpdate indicates that the properties of the image are now available.
- See Also:
Image.getProperty(java.lang.String, java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
RIGHT_ALIGNMENT static float
RIGHT_ALIGNMENTEase-of-use constant forgetAlignmentX
.public static final float RIGHT_ALIGNMENT-
Ease-of-use constant for
getAlignmentX
. Specifies an alignment to the right side of the component.
SOMEBITS static int
SOMEBITSThis flag in the infoflags argument to imageUpdate indicates that more pixels needed for drawing a scaled variation of the image are available.public static final int SOMEBITS-
This flag in the infoflags argument to imageUpdate indicates that more pixels needed for drawing a scaled variation of the image are available. The bounding box of the new pixels can be taken from the x, y, width, and height arguments to the imageUpdate callback method.
- See Also:
Graphics.drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
TOP_ALIGNMENT static float
TOP_ALIGNMENTEase-of-use constant forgetAlignmentY()
.public static final float TOP_ALIGNMENT-
Ease-of-use constant for
getAlignmentY()
. Specifies an alignment to the top of the component.
WIDTH static int
WIDTHThis flag in the infoflags argument to imageUpdate indicates that the width of the base image is now available and can be taken from the width argument to the imageUpdate callback method.public static final int WIDTH-
This flag in the infoflags argument to imageUpdate indicates that the width of the base image is now available and can be taken from the width argument to the imageUpdate callback method.
- See Also:
Image.getWidth(java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
, Constant Field Values
-
-
-
Basic Attribute Methods Modifier and Type Method and Description applyComponentOrientation void
applyComponentOrientation(ComponentOrientation o)Sets theComponentOrientation
property of this container and all components contained within it.public void applyComponentOrientation(ComponentOrientation o)-
Sets the
ComponentOrientation
property of this container and all components contained within it.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Overrides:
applyComponentOrientation
in classComponent
- Parameters:
o
- the new component orientation of this container and the components contained within it.- Throws:
java.lang.NullPointerException
- iforientation
is null.- Since:
- 1.4
- See Also:
Component.setComponentOrientation(java.awt.ComponentOrientation)
,Component.getComponentOrientation()
,invalidate()
disable void
disable()Deprecated. As of JDK version 1.1, replaced bysetEnabled(boolean)
.@Deprecated public void disable()Deprecated. As of JDK version 1.1, replaced bysetEnabled(boolean)
.enable void
enable()Deprecated. As of JDK version 1.1, replaced bysetEnabled(boolean)
.@Deprecated public void enable()Deprecated. As of JDK version 1.1, replaced bysetEnabled(boolean)
.enable void
enable(boolean b)Deprecated. As of JDK version 1.1, replaced bysetEnabled(boolean)
.@Deprecated public void enable(boolean b)Deprecated. As of JDK version 1.1, replaced bysetEnabled(boolean)
.enableInputMethods void
enableInputMethods(boolean enable)Enables or disables input method support for this component.public void enableInputMethods(boolean enable)-
Description copied from class:
Component
Enables or disables input method support for this component. If input method support is enabled and the component also processes key events, incoming events are offered to the current input method and will only be processed by the component or dispatched to its listeners if the input method does not consume them. By default, input method support is enabled.- Parameters:
enable
- true to enable, false to disable- Since:
- 1.2
- See Also:
Component.processKeyEvent(java.awt.event.KeyEvent)
getAccessibleContext javax.accessibility.AccessibleContext
getAccessibleContext()Gets theAccessibleContext
associated with thisComponent
.public javax.accessibility.AccessibleContext getAccessibleContext()-
Description copied from class:
Component
Gets theAccessibleContext
associated with thisComponent
. The method implemented by this base class returns null. Classes that extendComponent
should implement this method to return theAccessibleContext
associated with the subclass.- Returns:
- the
AccessibleContext
of thisComponent
- Since:
- 1.3
getBackground Color
getBackground()Gets the background color of this component.public Color getBackground()-
Description copied from class:
Component
Gets the background color of this component.- Returns:
- this component's background color; if this component does not have a background color, the background color of its parent is returned
- Since:
- JDK1.0
- See Also:
Component.setBackground(java.awt.Color)
getColorModel java.awt.image.ColorModel
getColorModel()Gets the instance ofColorModel
used to display the component on the output device.public java.awt.image.ColorModel getColorModel()-
Description copied from class:
Component
Gets the instance ofColorModel
used to display the component on the output device.- Returns:
- the color model used by this component
- Since:
- JDK1.0
- See Also:
ColorModel
,ComponentPeer.getColorModel()
,Toolkit.getColorModel()
getComponentOrientation ComponentOrientation
getComponentOrientation()Retrieves the language-sensitive orientation that is to be used to order the elements or text within this component.public ComponentOrientation getComponentOrientation()-
Description copied from class:
Component
Retrieves the language-sensitive orientation that is to be used to order the elements or text within this component.LayoutManager
andComponent
subclasses that wish to respect orientation should call this method to get the component's orientation before performing layout or drawing.- See Also:
ComponentOrientation
getCursor Cursor
getCursor()Gets the cursor set in the component.public Cursor getCursor()-
Description copied from class:
Component
Gets the cursor set in the component. If the component does not have a cursor set, the cursor of its parent is returned. If no cursor is set in the entire hierarchy,Cursor.DEFAULT_CURSOR
is returned.- Since:
- JDK1.1
- See Also:
Component.setCursor(java.awt.Cursor)
getFont Font
getFont()Gets the font of this component.public Font getFont()-
Description copied from class:
Component
Gets the font of this component.- Specified by:
getFont
in interfaceMenuContainer
- Returns:
- this component's font; if a font has not been set for this component, the font of its parent is returned
- Since:
- JDK1.0
- See Also:
Component.setFont(java.awt.Font)
getForeground Color
getForeground()Gets the foreground color of this component.public Color getForeground()-
Description copied from class:
Component
Gets the foreground color of this component.- Returns:
- this component's foreground color; if this component does not have a foreground color, the foreground color of its parent is returned
- Since:
- JDK1.0
- See Also:
Component.setForeground(java.awt.Color)
getLocale java.util.Locale
getLocale()Gets the locale of this component.public java.util.Locale getLocale()-
Description copied from class:
Component
Gets the locale of this component.- Returns:
- this component's locale; if this component does not have a locale, the locale of its parent is returned
- Throws:
IllegalComponentStateException
- if theComponent
does not have its own locale and has not yet been added to a containment hierarchy such that the locale can be determined from the containing parent- Since:
- JDK1.1
- See Also:
Component.setLocale(java.util.Locale)
getName java.lang.String
getName()Gets the name of the component.public java.lang.String getName()-
Description copied from class:
Component
Gets the name of the component.- Returns:
- this component's name
- Since:
- JDK1.1
- See Also:
Component.setName(java.lang.String)
getParent Container
getParent()Gets the parent of this component.hide void
hide()Deprecated. As of JDK version 1.1, replaced bysetVisible(boolean)
.@Deprecated public void hide()Deprecated. As of JDK version 1.1, replaced bysetVisible(boolean)
.isBackgroundSet boolean
isBackgroundSet()Returns whether the background color has been explicitly set for this Component.public boolean isBackgroundSet()-
Description copied from class:
Component
Returns whether the background color has been explicitly set for this Component. If this method returnsfalse
, this Component is inheriting its background color from an ancestor.- Returns:
true
if the background color has been explicitly set for this Component;false
otherwise.- Since:
- 1.4
isCursorSet boolean
isCursorSet()Returns whether the cursor has been explicitly set for this Component.public boolean isCursorSet()-
Description copied from class:
Component
Returns whether the cursor has been explicitly set for this Component. If this method returnsfalse
, this Component is inheriting its cursor from an ancestor.- Returns:
true
if the cursor has been explicitly set for this Component;false
otherwise.- Since:
- 1.4
isDisplayable boolean
isDisplayable()Determines whether this component is displayable.public boolean isDisplayable()-
Description copied from class:
Component
Determines whether this component is displayable. A component is displayable when it is connected to a native screen resource.A component is made displayable either when it is added to a displayable containment hierarchy or when its containment hierarchy is made displayable. A containment hierarchy is made displayable when its ancestor window is either packed or made visible.
A component is made undisplayable either when it is removed from a displayable containment hierarchy or when its containment hierarchy is made undisplayable. A containment hierarchy is made undisplayable when its ancestor window is disposed.
- Returns:
true
if the component is displayable,false
otherwise- Since:
- 1.2
- See Also:
add(Component)
,Window.pack()
,Window.show()
,remove(Component)
,Window.dispose()
isDoubleBuffered boolean
isDoubleBuffered()Returns true if this component is painted to an offscreen image ("buffer") that's copied to the screen later.public boolean isDoubleBuffered()-
Description copied from class:
Component
Returns true if this component is painted to an offscreen image ("buffer") that's copied to the screen later. Component subclasses that support double buffering should override this method to return true if double buffering is enabled.- Returns:
- false by default
isEnabled boolean
isEnabled()Determines whether this component is enabled.public boolean isEnabled()-
Description copied from class:
Component
Determines whether this component is enabled. An enabled component can respond to user input and generate events. Components are enabled initially by default. A component may be enabled or disabled by calling itssetEnabled
method.- Returns:
true
if the component is enabled,false
otherwise- Since:
- JDK1.0
- See Also:
Component.setEnabled(boolean)
isFontSet boolean
isFontSet()Returns whether the font has been explicitly set for this Component.public boolean isFontSet()-
Description copied from class:
Component
Returns whether the font has been explicitly set for this Component. If this method returnsfalse
, this Component is inheriting its font from an ancestor.- Returns:
true
if the font has been explicitly set for this Component;false
otherwise.- Since:
- 1.4
isForegroundSet boolean
isForegroundSet()Returns whether the foreground color has been explicitly set for this Component.public boolean isForegroundSet()-
Description copied from class:
Component
Returns whether the foreground color has been explicitly set for this Component. If this method returnsfalse
, this Component is inheriting its foreground color from an ancestor.- Returns:
true
if the foreground color has been explicitly set for this Component;false
otherwise.- Since:
- 1.4
isLightweight boolean
isLightweight()A lightweight component doesn't have a native toolkit peer.public boolean isLightweight()-
Description copied from class:
Component
A lightweight component doesn't have a native toolkit peer. Subclasses ofComponent
andContainer
, other than the ones defined in this package likeButton
orScrollbar
, are lightweight. All of the Swing components are lightweights.This method will always return
false
if this component is not displayable because it is impossible to determine the weight of an undisplayable component.- Returns:
- true if this component has a lightweight peer; false if it has a native peer or no peer
- Since:
- 1.2
- See Also:
Component.isDisplayable()
isOpaque boolean
isOpaque()Returns true if this component is completely opaque, returns false by default.public boolean isOpaque()-
Description copied from class:
Component
Returns true if this component is completely opaque, returns false by default.An opaque component paints every pixel within its rectangular region. A non-opaque component paints only some of its pixels, allowing the pixels underneath it to "show through". A component that does not fully paint its pixels therefore provides a degree of transparency.
Subclasses that guarantee to always completely paint their contents should override this method and return true.
- Returns:
- true if this component is completely opaque
- Since:
- 1.2
- See Also:
Component.isLightweight()
isShowing boolean
isShowing()Determines whether this component is showing on screen.public boolean isShowing()-
Description copied from class:
Component
Determines whether this component is showing on screen. This means that the component must be visible, and it must be in a container that is visible and showing.Note: sometimes there is no way to detect whether the
Component
is actually visible to the user. This can happen when:- the component has been added to a visible
ScrollPane
but theComponent
is not currently in the scroll pane's view port. - the
Component
is obscured by anotherComponent
orContainer
.
- Returns:
true
if the component is showing,false
otherwise- Since:
- JDK1.0
- See Also:
Component.setVisible(boolean)
- the component has been added to a visible
isVisible boolean
isVisible()Determines whether this component should be visible when its parent is visible.public boolean isVisible()-
Description copied from class:
Component
Determines whether this component should be visible when its parent is visible. Components are initially visible, with the exception of top level components such asFrame
objects.- Returns:
true
if the component is visible,false
otherwise- Since:
- JDK1.0
- See Also:
Component.setVisible(boolean)
setBackground void
setBackground(Color c)Sets the background color of this component.public void setBackground(Color c)-
Description copied from class:
Component
Sets the background color of this component.The background color affects each component differently and the parts of the component that are affected by the background color may differ between operating systems.
- Parameters:
c
- the color to become this component's color; if this parameter isnull
, then this component will inherit the background color of its parent- Since:
- JDK1.0
- See Also:
Component.getBackground()
setComponentOrientation void
setComponentOrientation(ComponentOrientation o)Sets the language-sensitive orientation that is to be used to order the elements or text within this component.public void setComponentOrientation(ComponentOrientation o)-
Description copied from class:
Component
Sets the language-sensitive orientation that is to be used to order the elements or text within this component. Language-sensitiveLayoutManager
andComponent
subclasses will use this property to determine how to lay out and draw components.At construction time, a component's orientation is set to
ComponentOrientation.UNKNOWN
, indicating that it has not been specified explicitly. The UNKNOWN orientation behaves the same asComponentOrientation.LEFT_TO_RIGHT
.To set the orientation of a single component, use this method. To set the orientation of an entire component hierarchy, use
applyComponentOrientation
.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- See Also:
ComponentOrientation
,Component.invalidate()
setCursor void
setCursor(Cursor cursor)Sets the cursor image to the specified cursor.public void setCursor(Cursor cursor)-
Description copied from class:
Component
Sets the cursor image to the specified cursor. This cursor image is displayed when thecontains
method for this component returns true for the current cursor location, and this Component is visible, displayable, and enabled. Setting the cursor of aContainer
causes that cursor to be displayed within all of the container's subcomponents, except for those that have a non-null
cursor.The method may have no visual effect if the Java platform implementation and/or the native system do not support changing the mouse cursor shape.
- Parameters:
cursor
- One of the constants defined by theCursor
class; if this parameter isnull
then this component will inherit the cursor of its parent- Since:
- JDK1.1
- See Also:
Component.isEnabled()
,Component.isShowing()
,Component.getCursor()
,Component.contains(int, int)
,Toolkit.createCustomCursor(java.awt.Image, java.awt.Point, java.lang.String)
,Cursor
setEnabled void
setEnabled(boolean b)Enables or disables this component, depending on the value of the parameterb
.public void setEnabled(boolean b)-
Description copied from class:
Component
Enables or disables this component, depending on the value of the parameterb
. An enabled component can respond to user input and generate events. Components are enabled initially by default.Note: Disabling a lightweight component does not prevent it from receiving MouseEvents.
Note: Disabling a heavyweight container prevents all components in this container from receiving any input events. But disabling a lightweight container affects only this container.
- Parameters:
b
- Iftrue
, this component is enabled; otherwise this component is disabled- Since:
- JDK1.1
- See Also:
Component.isEnabled()
,Component.isLightweight()
setFont void
setFont(Font f)Sets the font of this container.public void setFont(Font f)-
Sets the font of this container.
This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Overrides:
setFont
in classComponent
- Parameters:
f
- The font to become this container's font.- Since:
- JDK1.0
- See Also:
Component.getFont()
,invalidate()
setForeground void
setForeground(Color c)Sets the foreground color of this component.public void setForeground(Color c)-
Description copied from class:
Component
Sets the foreground color of this component.- Parameters:
c
- the color to become this component's foreground color; if this parameter isnull
then this component will inherit the foreground color of its parent- Since:
- JDK1.0
- See Also:
Component.getForeground()
setLocale void
setLocale(java.util.Locale l)Sets the locale of this component.public void setLocale(java.util.Locale l)-
Description copied from class:
Component
Sets the locale of this component. This is a bound property.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
l
- the locale to become this component's locale- Since:
- JDK1.1
- See Also:
Component.getLocale()
,Component.invalidate()
setName void
setName(java.lang.String name)Sets the name of the component to the specified string.public void setName(java.lang.String name)-
Description copied from class:
Component
Sets the name of the component to the specified string.- Parameters:
name
- the string that is to be this component's name- Since:
- JDK1.1
- See Also:
Component.getName()
setVisible void
setVisible(boolean b)Shows or hides this component depending on the value of parameterb
.public void setVisible(boolean b)-
Description copied from class:
Component
Shows or hides this component depending on the value of parameterb
.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
b
- iftrue
, shows this component; otherwise, hides this component- Since:
- JDK1.1
- See Also:
Component.isVisible()
,Component.invalidate()
show void
show()Deprecated. As of JDK version 1.1, replaced bysetVisible(boolean)
.@Deprecated public void show()Deprecated. As of JDK version 1.1, replaced bysetVisible(boolean)
.show void
show(boolean b)Deprecated. As of JDK version 1.1, replaced bysetVisible(boolean)
.@Deprecated public void show(boolean b)Deprecated. As of JDK version 1.1, replaced bysetVisible(boolean)
. -
-
Event Support Methods Modifier and Type Method and Description action boolean
action(Event evt, java.lang.Object what)Deprecated. As of JDK version 1.1, should register this component as ActionListener on component which fires action events.Deprecated. As of JDK version 1.1, should register this component as ActionListener on component which fires action events.coalesceEvents protected AWTEvent
coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)Potentially coalesce an event being posted with an existing event.-
Description copied from class:
Component
Potentially coalesce an event being posted with an existing event. This method is called byEventQueue.postEvent
if an event with the same ID as the event to be posted is found in the queue (both events must have this component as their source). This method either returns a coalesced event which replaces the existing event (and the new event is then discarded), ornull
to indicate that no combining should be done (add the second event to the end of the queue). Either event parameter may be modified and returned, as the other one is discarded unlessnull
is returned.This implementation of
coalesceEvents
coalesces two event types: mouse move (and drag) events, and paint (and update) events. For mouse move events the last event is always returned, causing intermediate moves to be discarded. For paint events, the new event is coalesced into a complexRepaintArea
in the peer. The newAWTEvent
is always returned.- Parameters:
existingEvent
- the event already on theEventQueue
newEvent
- the event being posted to theEventQueue
- Returns:
- a coalesced event, or
null
indicating that no coalescing was done
deliverEvent void
deliverEvent(Event e)Deprecated. As of JDK version 1.1, replaced bydispatchEvent(AWTEvent e)
Deprecated. As of JDK version 1.1, replaced bydispatchEvent(AWTEvent e)
disableEvents protected void
disableEvents(long eventsToDisable)Disables the events defined by the specified event mask parameter from being delivered to this component.protected final void disableEvents(long eventsToDisable)-
Description copied from class:
Component
Disables the events defined by the specified event mask parameter from being delivered to this component.- Parameters:
eventsToDisable
- the event mask defining the event types- Since:
- JDK1.1
- See Also:
Component.enableEvents(long)
dispatchEvent void
dispatchEvent(AWTEvent e)Dispatches an event to this component or one of its sub components.enableEvents protected void
enableEvents(long eventsToEnable)Enables the events defined by the specified event mask parameter to be delivered to this component.protected final void enableEvents(long eventsToEnable)-
Description copied from class:
Component
Enables the events defined by the specified event mask parameter to be delivered to this component.Event types are automatically enabled when a listener for that event type is added to the component.
This method only needs to be invoked by subclasses of
Component
which desire to have the specified event types delivered toprocessEvent
regardless of whether or not a listener is registered.- Parameters:
eventsToEnable
- the event mask defining the event types- Since:
- JDK1.1
- See Also:
Component.processEvent(java.awt.AWTEvent)
,Component.disableEvents(long)
,AWTEvent
firePropertyChange protected void
firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)Support for reporting bound property changes for boolean properties.protected void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)-
Description copied from class:
Component
Support for reporting bound property changes for boolean properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.- Parameters:
propertyName
- the property whose value has changedoldValue
- the property's previous valuenewValue
- the property's new value- Since:
- 1.4
firePropertyChange void
firePropertyChange(java.lang.String propertyName, byte oldValue, byte newValue)Reports a bound property change.public void firePropertyChange(java.lang.String propertyName, byte oldValue, byte newValue)-
Description copied from class:
Component
Reports a bound property change.- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the property (as a byte)newValue
- the new value of the property (as a byte)- Since:
- 1.5
- See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
firePropertyChange void
firePropertyChange(java.lang.String propertyName, char oldValue, char newValue)Reports a bound property change.public void firePropertyChange(java.lang.String propertyName, char oldValue, char newValue)-
Description copied from class:
Component
Reports a bound property change.- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the property (as a char)newValue
- the new value of the property (as a char)- Since:
- 1.5
- See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
firePropertyChange void
firePropertyChange(java.lang.String propertyName, double oldValue, double newValue)Reports a bound property change.public void firePropertyChange(java.lang.String propertyName, double oldValue, double newValue)-
Description copied from class:
Component
Reports a bound property change.- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the property (as a double)newValue
- the new value of the property (as a double)- Since:
- 1.5
- See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
firePropertyChange void
firePropertyChange(java.lang.String propertyName, float oldValue, float newValue)Reports a bound property change.public void firePropertyChange(java.lang.String propertyName, float oldValue, float newValue)-
Description copied from class:
Component
Reports a bound property change.- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the property (as a float)newValue
- the new value of the property (as a float)- Since:
- 1.5
- See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
firePropertyChange protected void
firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)Support for reporting bound property changes for integer properties.protected void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)-
Description copied from class:
Component
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.- Parameters:
propertyName
- the property whose value has changedoldValue
- the property's previous valuenewValue
- the property's new value- Since:
- 1.4
firePropertyChange void
firePropertyChange(java.lang.String propertyName, long oldValue, long newValue)Reports a bound property change.public void firePropertyChange(java.lang.String propertyName, long oldValue, long newValue)-
Description copied from class:
Component
Reports a bound property change.- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the property (as a long)newValue
- the new value of the property (as a long)- Since:
- 1.5
- See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
firePropertyChange protected void
firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)Support for reporting bound property changes for Object properties.protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)-
Description copied from class:
Component
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.- Parameters:
propertyName
- the property whose value has changedoldValue
- the property's previous valuenewValue
- the property's new value
firePropertyChange void
firePropertyChange(java.lang.String propertyName, short oldValue, short newValue)Reports a bound property change.public void firePropertyChange(java.lang.String propertyName, short oldValue, short newValue)-
Description copied from class:
Component
Reports a bound property change.- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the property (as a short)newValue
- the old value of the property (as a short)- Since:
- 1.5
- See Also:
Component.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object)
getListeners <T extends java.util.EventListener> T[]
getListeners(java.lang.Class<T> listenerType)Returns an array of all the objects currently registered asFooListener
s upon thisContainer
.public <T extends java.util.EventListener> T[] getListeners(java.lang.Class<T> listenerType)-
Returns an array of all the objects currently registered as
FooListener
s upon thisContainer
.FooListener
s are registered using theaddFooListener
method.You can specify the
listenerType
argument with a class literal, such asFooListener.class
. For example, you can query aContainer
c
for its container listeners with the following code:ContainerListener[] cls = (ContainerListener[])(c.getListeners(ContainerListener.class));
If no such listeners exist, this method returns an empty array.- Overrides:
getListeners
in classComponent
- Parameters:
listenerType
- the type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
- Returns:
- an array of all objects registered as
FooListener
s on this container, or an empty array if no such listeners have been added - Throws:
java.lang.ClassCastException
- iflistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
java.lang.NullPointerException
- iflistenerType
isnull
- Since:
- 1.3
- See Also:
getContainerListeners()
handleEvent boolean
handleEvent(Event evt)Deprecated. As of JDK version 1.1 replaced by processEvent(AWTEvent).Deprecated. As of JDK version 1.1 replaced by processEvent(AWTEvent).keyDown boolean
keyDown(Event evt, int key)Deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).Deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).keyUp boolean
keyUp(Event evt, int key)Deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).Deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).mouseDown boolean
mouseDown(Event evt, int x, int y)Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).mouseDrag boolean
mouseDrag(Event evt, int x, int y)Deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).Deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).mouseEnter boolean
mouseEnter(Event evt, int x, int y)Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).mouseExit boolean
mouseExit(Event evt, int x, int y)Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).mouseMove boolean
mouseMove(Event evt, int x, int y)Deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).Deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).mouseUp boolean
mouseUp(Event evt, int x, int y)Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).Deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).postEvent boolean
postEvent(Event e)Deprecated. As of JDK version 1.1, replaced by dispatchEvent(AWTEvent).Deprecated. As of JDK version 1.1, replaced by dispatchEvent(AWTEvent).processComponentEvent protected void
processComponentEvent(ComponentEvent e)Processes component events occurring on this component by dispatching them to any registeredComponentListener
objects.protected void processComponentEvent(ComponentEvent e)-
Description copied from class:
Component
Processes component events occurring on this component by dispatching them to any registeredComponentListener
objects.This method is not called unless component events are enabled for this component. Component events are enabled when one of the following occurs:
- A
ComponentListener
object is registered viaaddComponentListener
. - Component events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the component event- Since:
- JDK1.1
- See Also:
ComponentEvent
,ComponentListener
,Component.addComponentListener(java.awt.event.ComponentListener)
,Component.enableEvents(long)
- A
processContainerEvent protected void
processContainerEvent(ContainerEvent e)Processes container events occurring on this container by dispatching them to any registered ContainerListener objects.protected void processContainerEvent(ContainerEvent e)-
Processes container events occurring on this container by dispatching them to any registered ContainerListener objects. NOTE: This method will not be called unless container events are enabled for this component; this happens when one of the following occurs:
- A ContainerListener object is registered via
addContainerListener
- Container events are enabled via
enableEvents
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the container event- See Also:
Component.enableEvents(long)
- A ContainerListener object is registered via
processEvent protected void
processEvent(AWTEvent e)Processes events on this container.protected void processEvent(AWTEvent e)-
Processes events on this container. If the event is a
ContainerEvent
, it invokes theprocessContainerEvent
method, else it invokes its superclass'sprocessEvent
.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Overrides:
processEvent
in classComponent
- Parameters:
e
- the event- See Also:
Component.processComponentEvent(java.awt.event.ComponentEvent)
,Component.processFocusEvent(java.awt.event.FocusEvent)
,Component.processKeyEvent(java.awt.event.KeyEvent)
,Component.processMouseEvent(java.awt.event.MouseEvent)
,Component.processMouseMotionEvent(java.awt.event.MouseEvent)
,Component.processInputMethodEvent(java.awt.event.InputMethodEvent)
,Component.processHierarchyEvent(java.awt.event.HierarchyEvent)
,Component.processMouseWheelEvent(java.awt.event.MouseWheelEvent)
processFocusEvent protected void
processFocusEvent(FocusEvent e)Processes focus events occurring on this component by dispatching them to any registeredFocusListener
objects.protected void processFocusEvent(FocusEvent e)-
Description copied from class:
Component
Processes focus events occurring on this component by dispatching them to any registeredFocusListener
objects.This method is not called unless focus events are enabled for this component. Focus events are enabled when one of the following occurs:
- A
FocusListener
object is registered viaaddFocusListener
. - Focus events are enabled via
enableEvents
.
If focus events are enabled for a
Component
, the currentKeyboardFocusManager
determines whether or not a focus event should be dispatched to registeredFocusListener
objects. If the events are to be dispatched, theKeyboardFocusManager
calls theComponent
'sdispatchEvent
method, which results in a call to theComponent
'sprocessFocusEvent
method.If focus events are enabled for a
Component
, calling theComponent
'sdispatchEvent
method with aFocusEvent
as the argument will result in a call to theComponent
'sprocessFocusEvent
method regardless of the currentKeyboardFocusManager
.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the focus event- Since:
- JDK1.1
- See Also:
FocusEvent
,FocusListener
,KeyboardFocusManager
,Component.addFocusListener(java.awt.event.FocusListener)
,Component.enableEvents(long)
,Component.dispatchEvent(java.awt.AWTEvent)
- A
processHierarchyBoundsEvent protected void
processHierarchyBoundsEvent(HierarchyEvent e)Processes hierarchy bounds events occurring on this component by dispatching them to any registeredHierarchyBoundsListener
objects.protected void processHierarchyBoundsEvent(HierarchyEvent e)-
Description copied from class:
Component
Processes hierarchy bounds events occurring on this component by dispatching them to any registeredHierarchyBoundsListener
objects.This method is not called unless hierarchy bounds events are enabled for this component. Hierarchy bounds events are enabled when one of the following occurs:
- An
HierarchyBoundsListener
object is registered viaaddHierarchyBoundsListener
. - Hierarchy bounds events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the hierarchy event- Since:
- 1.3
- See Also:
HierarchyEvent
,HierarchyBoundsListener
,Component.addHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
,Component.enableEvents(long)
- An
processHierarchyEvent protected void
processHierarchyEvent(HierarchyEvent e)Processes hierarchy events occurring on this component by dispatching them to any registeredHierarchyListener
objects.protected void processHierarchyEvent(HierarchyEvent e)-
Description copied from class:
Component
Processes hierarchy events occurring on this component by dispatching them to any registeredHierarchyListener
objects.This method is not called unless hierarchy events are enabled for this component. Hierarchy events are enabled when one of the following occurs:
- An
HierarchyListener
object is registered viaaddHierarchyListener
. - Hierarchy events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the hierarchy event- Since:
- 1.3
- See Also:
HierarchyEvent
,HierarchyListener
,Component.addHierarchyListener(java.awt.event.HierarchyListener)
,Component.enableEvents(long)
- An
processInputMethodEvent protected void
processInputMethodEvent(InputMethodEvent e)Processes input method events occurring on this component by dispatching them to any registeredInputMethodListener
objects.protected void processInputMethodEvent(InputMethodEvent e)-
Description copied from class:
Component
Processes input method events occurring on this component by dispatching them to any registeredInputMethodListener
objects.This method is not called unless input method events are enabled for this component. Input method events are enabled when one of the following occurs:
- An
InputMethodListener
object is registered viaaddInputMethodListener
. - Input method events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the input method event- Since:
- 1.2
- See Also:
InputMethodEvent
,InputMethodListener
,Component.addInputMethodListener(java.awt.event.InputMethodListener)
,Component.enableEvents(long)
- An
processKeyEvent protected void
processKeyEvent(KeyEvent e)Processes key events occurring on this component by dispatching them to any registeredKeyListener
objects.protected void processKeyEvent(KeyEvent e)-
Description copied from class:
Component
Processes key events occurring on this component by dispatching them to any registeredKeyListener
objects.This method is not called unless key events are enabled for this component. Key events are enabled when one of the following occurs:
- A
KeyListener
object is registered viaaddKeyListener
. - Key events are enabled via
enableEvents
.
If key events are enabled for a
Component
, the currentKeyboardFocusManager
determines whether or not a key event should be dispatched to registeredKeyListener
objects. TheDefaultKeyboardFocusManager
will not dispatch key events to aComponent
that is not the focus owner or is not showing.As of J2SE 1.4,
KeyEvent
s are redirected to the focus owner. Please see the Focus Specification for further information.Calling a
Component
'sdispatchEvent
method with aKeyEvent
as the argument will result in a call to theComponent
'sprocessKeyEvent
method regardless of the currentKeyboardFocusManager
as long as the component is showing, focused, and enabled, and key events are enabled on it.If the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the key event- Since:
- JDK1.1
- See Also:
KeyEvent
,KeyListener
,KeyboardFocusManager
,DefaultKeyboardFocusManager
,Component.processEvent(java.awt.AWTEvent)
,Component.dispatchEvent(java.awt.AWTEvent)
,Component.addKeyListener(java.awt.event.KeyListener)
,Component.enableEvents(long)
,Component.isShowing()
- A
processMouseEvent protected void
processMouseEvent(MouseEvent e)Processes mouse events occurring on this component by dispatching them to any registeredMouseListener
objects.protected void processMouseEvent(MouseEvent e)-
Description copied from class:
Component
Processes mouse events occurring on this component by dispatching them to any registeredMouseListener
objects.This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:
- A
MouseListener
object is registered viaaddMouseListener
. - Mouse events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the mouse event- Since:
- JDK1.1
- See Also:
MouseEvent
,MouseListener
,Component.addMouseListener(java.awt.event.MouseListener)
,Component.enableEvents(long)
- A
processMouseMotionEvent protected void
processMouseMotionEvent(MouseEvent e)Processes mouse motion events occurring on this component by dispatching them to any registeredMouseMotionListener
objects.protected void processMouseMotionEvent(MouseEvent e)-
Description copied from class:
Component
Processes mouse motion events occurring on this component by dispatching them to any registeredMouseMotionListener
objects.This method is not called unless mouse motion events are enabled for this component. Mouse motion events are enabled when one of the following occurs:
- A
MouseMotionListener
object is registered viaaddMouseMotionListener
. - Mouse motion events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the mouse motion event- Since:
- JDK1.1
- See Also:
MouseEvent
,MouseMotionListener
,Component.addMouseMotionListener(java.awt.event.MouseMotionListener)
,Component.enableEvents(long)
- A
processMouseWheelEvent protected void
processMouseWheelEvent(MouseWheelEvent e)Processes mouse wheel events occurring on this component by dispatching them to any registeredMouseWheelListener
objects.protected void processMouseWheelEvent(MouseWheelEvent e)-
Description copied from class:
Component
Processes mouse wheel events occurring on this component by dispatching them to any registeredMouseWheelListener
objects.This method is not called unless mouse wheel events are enabled for this component. Mouse wheel events are enabled when one of the following occurs:
- A
MouseWheelListener
object is registered viaaddMouseWheelListener
. - Mouse wheel events are enabled via
enableEvents
.
For information on how mouse wheel events are dispatched, see the class description for
MouseWheelEvent
.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the mouse wheel event- Since:
- 1.4
- See Also:
MouseWheelEvent
,MouseWheelListener
,Component.addMouseWheelListener(java.awt.event.MouseWheelListener)
,Component.enableEvents(long)
- A
-
-
Event Registration Methods Modifier and Type Method and Description addComponentListener void
addComponentListener(ComponentListener l)Adds the specified component listener to receive component events from this component.public void addComponentListener(ComponentListener l)-
Description copied from class:
Component
Adds the specified component listener to receive component events from this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the component listener- Since:
- JDK1.1
- See Also:
ComponentEvent
,ComponentListener
,Component.removeComponentListener(java.awt.event.ComponentListener)
,Component.getComponentListeners()
addContainerListener void
addContainerListener(ContainerListener l)Adds the specified container listener to receive container events from this container.public void addContainerListener(ContainerListener l)-
Adds the specified container listener to receive container events from this container. If l is null, no exception is thrown and no action is performed.
Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the container listener- See Also:
removeContainerListener(java.awt.event.ContainerListener)
,getContainerListeners()
addFocusListener void
addFocusListener(FocusListener l)Adds the specified focus listener to receive focus events from this component when this component gains input focus.public void addFocusListener(FocusListener l)-
Description copied from class:
Component
Adds the specified focus listener to receive focus events from this component when this component gains input focus. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the focus listener- Since:
- JDK1.1
- See Also:
FocusEvent
,FocusListener
,Component.removeFocusListener(java.awt.event.FocusListener)
,Component.getFocusListeners()
addHierarchyBoundsListener void
addHierarchyBoundsListener(HierarchyBoundsListener l)Adds the specified hierarchy bounds listener to receive hierarchy bounds events from this component when the hierarchy to which this container belongs changes.public void addHierarchyBoundsListener(HierarchyBoundsListener l)-
Description copied from class:
Component
Adds the specified hierarchy bounds listener to receive hierarchy bounds events from this component when the hierarchy to which this container belongs changes. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the hierarchy bounds listener- Since:
- 1.3
- See Also:
HierarchyEvent
,HierarchyBoundsListener
,Component.removeHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
,Component.getHierarchyBoundsListeners()
addHierarchyListener void
addHierarchyListener(HierarchyListener l)Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes.public void addHierarchyListener(HierarchyListener l)-
Description copied from class:
Component
Adds the specified hierarchy listener to receive hierarchy changed events from this component when the hierarchy to which this container belongs changes. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the hierarchy listener- Since:
- 1.3
- See Also:
HierarchyEvent
,HierarchyListener
,Component.removeHierarchyListener(java.awt.event.HierarchyListener)
,Component.getHierarchyListeners()
addInputMethodListener void
addInputMethodListener(InputMethodListener l)Adds the specified input method listener to receive input method events from this component.public void addInputMethodListener(InputMethodListener l)-
Description copied from class:
Component
Adds the specified input method listener to receive input method events from this component. A component will only receive input method events from input methods if it also overridesgetInputMethodRequests
to return anInputMethodRequests
instance. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the input method listener- Since:
- 1.2
- See Also:
InputMethodEvent
,InputMethodListener
,Component.removeInputMethodListener(java.awt.event.InputMethodListener)
,Component.getInputMethodListeners()
,Component.getInputMethodRequests()
addKeyListener void
addKeyListener(KeyListener l)Adds the specified key listener to receive key events from this component.public void addKeyListener(KeyListener l)-
Description copied from class:
Component
Adds the specified key listener to receive key events from this component. If l is null, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the key listener.- Since:
- JDK1.1
- See Also:
KeyEvent
,KeyListener
,Component.removeKeyListener(java.awt.event.KeyListener)
,Component.getKeyListeners()
addMouseListener void
addMouseListener(MouseListener l)Adds the specified mouse listener to receive mouse events from this component.public void addMouseListener(MouseListener l)-
Description copied from class:
Component
Adds the specified mouse listener to receive mouse events from this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the mouse listener- Since:
- JDK1.1
- See Also:
MouseEvent
,MouseListener
,Component.removeMouseListener(java.awt.event.MouseListener)
,Component.getMouseListeners()
addMouseMotionListener void
addMouseMotionListener(MouseMotionListener l)Adds the specified mouse motion listener to receive mouse motion events from this component.public void addMouseMotionListener(MouseMotionListener l)-
Description copied from class:
Component
Adds the specified mouse motion listener to receive mouse motion events from this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the mouse motion listener- Since:
- JDK1.1
- See Also:
MouseEvent
,MouseMotionListener
,Component.removeMouseMotionListener(java.awt.event.MouseMotionListener)
,Component.getMouseMotionListeners()
addMouseWheelListener void
addMouseWheelListener(MouseWheelListener l)Adds the specified mouse wheel listener to receive mouse wheel events from this component.public void addMouseWheelListener(MouseWheelListener l)-
Description copied from class:
Component
Adds the specified mouse wheel listener to receive mouse wheel events from this component. Containers also receive mouse wheel events from sub-components.For information on how mouse wheel events are dispatched, see the class description for
MouseWheelEvent
.If l is
null
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the mouse wheel listener- Since:
- 1.4
- See Also:
MouseWheelEvent
,MouseWheelListener
,Component.removeMouseWheelListener(java.awt.event.MouseWheelListener)
,Component.getMouseWheelListeners()
addPropertyChangeListener void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)-
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class, including the following:
- this Container's font ("font")
- this Container's background color ("background")
- this Container's foreground color ("foreground")
- this Container's focusability ("focusable")
- this Container's focus traversal keys enabled state ("focusTraversalKeysEnabled")
- this Container's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
- this Container's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
- this Container's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
- this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS ("downCycleFocusTraversalKeys")
- this Container's focus traversal policy ("focusTraversalPolicy")
- this Container's focus-cycle-root state ("focusCycleRoot")
If listener is null, no exception is thrown and no action is performed.
- Overrides:
addPropertyChangeListener
in classComponent
- Parameters:
listener
- the PropertyChangeListener to be added- See Also:
Component.removePropertyChangeListener(java.beans.PropertyChangeListener)
,addPropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
addPropertyChangeListener void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list for a specific property.public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)-
Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined, or one of the following defaults:
- this Container's font ("font")
- this Container's background color ("background")
- this Container's foreground color ("foreground")
- this Container's focusability ("focusable")
- this Container's focus traversal keys enabled state ("focusTraversalKeysEnabled")
- this Container's Set of FORWARD_TRAVERSAL_KEYS ("forwardFocusTraversalKeys")
- this Container's Set of BACKWARD_TRAVERSAL_KEYS ("backwardFocusTraversalKeys")
- this Container's Set of UP_CYCLE_TRAVERSAL_KEYS ("upCycleFocusTraversalKeys")
- this Container's Set of DOWN_CYCLE_TRAVERSAL_KEYS ("downCycleFocusTraversalKeys")
- this Container's focus traversal policy ("focusTraversalPolicy")
- this Container's focus-cycle-root state ("focusCycleRoot")
- this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")
- this Container's focus-traversal-policy-provider state("focusTraversalPolicyProvider")
If listener is null, no exception is thrown and no action is performed.
- Overrides:
addPropertyChangeListener
in classComponent
- Parameters:
propertyName
- one of the property names listed abovelistener
- the PropertyChangeListener to be added- See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)
,Component.removePropertyChangeListener(java.beans.PropertyChangeListener)
getComponentListeners ComponentListener[]
getComponentListeners()Returns an array of all the component listeners registered on this component.public ComponentListener[] getComponentListeners()-
Description copied from class:
Component
Returns an array of all the component listeners registered on this component.- Returns:
- all of this comonent's
ComponentListener
s or an empty array if no component listeners are currently registered - Since:
- 1.4
- See Also:
Component.addComponentListener(java.awt.event.ComponentListener)
,Component.removeComponentListener(java.awt.event.ComponentListener)
getContainerListeners ContainerListener[]
getContainerListeners()Returns an array of all the container listeners registered on this container.public ContainerListener[] getContainerListeners()-
Returns an array of all the container listeners registered on this container.
- Returns:
- all of this container's
ContainerListener
s or an empty array if no container listeners are currently registered - Since:
- 1.4
- See Also:
addContainerListener(java.awt.event.ContainerListener)
,removeContainerListener(java.awt.event.ContainerListener)
getFocusListeners FocusListener[]
getFocusListeners()Returns an array of all the focus listeners registered on this component.public FocusListener[] getFocusListeners()-
Description copied from class:
Component
Returns an array of all the focus listeners registered on this component.- Returns:
- all of this component's
FocusListener
s or an empty array if no component listeners are currently registered - Since:
- 1.4
- See Also:
Component.addFocusListener(java.awt.event.FocusListener)
,Component.removeFocusListener(java.awt.event.FocusListener)
getHierarchyBoundsListeners HierarchyBoundsListener[]
getHierarchyBoundsListeners()Returns an array of all the hierarchy bounds listeners registered on this component.public HierarchyBoundsListener[] getHierarchyBoundsListeners()-
Description copied from class:
Component
Returns an array of all the hierarchy bounds listeners registered on this component.- Returns:
- all of this component's
HierarchyBoundsListener
s or an empty array if no hierarchy bounds listeners are currently registered - Since:
- 1.4
- See Also:
Component.addHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
,Component.removeHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
getHierarchyListeners HierarchyListener[]
getHierarchyListeners()Returns an array of all the hierarchy listeners registered on this component.public HierarchyListener[] getHierarchyListeners()-
Description copied from class:
Component
Returns an array of all the hierarchy listeners registered on this component.- Returns:
- all of this component's
HierarchyListener
s or an empty array if no hierarchy listeners are currently registered - Since:
- 1.4
- See Also:
Component.addHierarchyListener(java.awt.event.HierarchyListener)
,Component.removeHierarchyListener(java.awt.event.HierarchyListener)
getInputMethodListeners InputMethodListener[]
getInputMethodListeners()Returns an array of all the input method listeners registered on this component.public InputMethodListener[] getInputMethodListeners()-
Description copied from class:
Component
Returns an array of all the input method listeners registered on this component.- Returns:
- all of this component's
InputMethodListener
s or an empty array if no input method listeners are currently registered - Since:
- 1.4
- See Also:
Component.addInputMethodListener(java.awt.event.InputMethodListener)
,Component.removeInputMethodListener(java.awt.event.InputMethodListener)
getKeyListeners KeyListener[]
getKeyListeners()Returns an array of all the key listeners registered on this component.public KeyListener[] getKeyListeners()-
Description copied from class:
Component
Returns an array of all the key listeners registered on this component.- Returns:
- all of this component's
KeyListener
s or an empty array if no key listeners are currently registered - Since:
- 1.4
- See Also:
Component.addKeyListener(java.awt.event.KeyListener)
,Component.removeKeyListener(java.awt.event.KeyListener)
getMouseListeners MouseListener[]
getMouseListeners()Returns an array of all the mouse listeners registered on this component.public MouseListener[] getMouseListeners()-
Description copied from class:
Component
Returns an array of all the mouse listeners registered on this component.- Returns:
- all of this component's
MouseListener
s or an empty array if no mouse listeners are currently registered - Since:
- 1.4
- See Also:
Component.addMouseListener(java.awt.event.MouseListener)
,Component.removeMouseListener(java.awt.event.MouseListener)
getMouseMotionListeners MouseMotionListener[]
getMouseMotionListeners()Returns an array of all the mouse motion listeners registered on this component.public MouseMotionListener[] getMouseMotionListeners()-
Description copied from class:
Component
Returns an array of all the mouse motion listeners registered on this component.- Returns:
- all of this component's
MouseMotionListener
s or an empty array if no mouse motion listeners are currently registered - Since:
- 1.4
- See Also:
Component.addMouseMotionListener(java.awt.event.MouseMotionListener)
,Component.removeMouseMotionListener(java.awt.event.MouseMotionListener)
getMouseWheelListeners MouseWheelListener[]
getMouseWheelListeners()Returns an array of all the mouse wheel listeners registered on this component.public MouseWheelListener[] getMouseWheelListeners()-
Description copied from class:
Component
Returns an array of all the mouse wheel listeners registered on this component.- Returns:
- all of this component's
MouseWheelListener
s or an empty array if no mouse wheel listeners are currently registered - Since:
- 1.4
- See Also:
Component.addMouseWheelListener(java.awt.event.MouseWheelListener)
,Component.removeMouseWheelListener(java.awt.event.MouseWheelListener)
getPropertyChangeListeners java.beans.PropertyChangeListener[]
getPropertyChangeListeners()Returns an array of all the property change listeners registered on this component.public java.beans.PropertyChangeListener[] getPropertyChangeListeners()-
Description copied from class:
Component
Returns an array of all the property change listeners registered on this component.- Returns:
- all of this component's
PropertyChangeListener
s or an empty array if no property change listeners are currently registered - Since:
- 1.4
- See Also:
Component.addPropertyChangeListener(java.beans.PropertyChangeListener)
,Component.removePropertyChangeListener(java.beans.PropertyChangeListener)
,Component.getPropertyChangeListeners(java.lang.String)
,PropertyChangeSupport.getPropertyChangeListeners()
getPropertyChangeListeners java.beans.PropertyChangeListener[]
getPropertyChangeListeners(java.lang.String propertyName)Returns an array of all the listeners which have been associated with the named property.public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)-
Description copied from class:
Component
Returns an array of all the listeners which have been associated with the named property.- Returns:
- all of the
PropertyChangeListener
s associated with the named property; if no such listeners have been added or ifpropertyName
isnull
, an empty array is returned - Since:
- 1.4
- See Also:
Component.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,Component.removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,Component.getPropertyChangeListeners()
removeComponentListener void
removeComponentListener(ComponentListener l)Removes the specified component listener so that it no longer receives component events from this component.public void removeComponentListener(ComponentListener l)-
Description copied from class:
Component
Removes the specified component listener so that it no longer receives component events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the component listener- Since:
- JDK1.1
- See Also:
ComponentEvent
,ComponentListener
,Component.addComponentListener(java.awt.event.ComponentListener)
,Component.getComponentListeners()
removeContainerListener void
removeContainerListener(ContainerListener l)Removes the specified container listener so it no longer receives container events from this container.public void removeContainerListener(ContainerListener l)-
Removes the specified container listener so it no longer receives container events from this container. If l is null, no exception is thrown and no action is performed.
Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the container listener- See Also:
addContainerListener(java.awt.event.ContainerListener)
,getContainerListeners()
removeFocusListener void
removeFocusListener(FocusListener l)Removes the specified focus listener so that it no longer receives focus events from this component.public void removeFocusListener(FocusListener l)-
Description copied from class:
Component
Removes the specified focus listener so that it no longer receives focus events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the focus listener- Since:
- JDK1.1
- See Also:
FocusEvent
,FocusListener
,Component.addFocusListener(java.awt.event.FocusListener)
,Component.getFocusListeners()
removeHierarchyBoundsListener void
removeHierarchyBoundsListener(HierarchyBoundsListener l)Removes the specified hierarchy bounds listener so that it no longer receives hierarchy bounds events from this component.public void removeHierarchyBoundsListener(HierarchyBoundsListener l)-
Description copied from class:
Component
Removes the specified hierarchy bounds listener so that it no longer receives hierarchy bounds events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the hierarchy bounds listener- Since:
- 1.3
- See Also:
HierarchyEvent
,HierarchyBoundsListener
,Component.addHierarchyBoundsListener(java.awt.event.HierarchyBoundsListener)
,Component.getHierarchyBoundsListeners()
removeHierarchyListener void
removeHierarchyListener(HierarchyListener l)Removes the specified hierarchy listener so that it no longer receives hierarchy changed events from this component.public void removeHierarchyListener(HierarchyListener l)-
Description copied from class:
Component
Removes the specified hierarchy listener so that it no longer receives hierarchy changed events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the hierarchy listener- Since:
- 1.3
- See Also:
HierarchyEvent
,HierarchyListener
,Component.addHierarchyListener(java.awt.event.HierarchyListener)
,Component.getHierarchyListeners()
removeInputMethodListener void
removeInputMethodListener(InputMethodListener l)Removes the specified input method listener so that it no longer receives input method events from this component.public void removeInputMethodListener(InputMethodListener l)-
Description copied from class:
Component
Removes the specified input method listener so that it no longer receives input method events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the input method listener- Since:
- 1.2
- See Also:
InputMethodEvent
,InputMethodListener
,Component.addInputMethodListener(java.awt.event.InputMethodListener)
,Component.getInputMethodListeners()
removeKeyListener void
removeKeyListener(KeyListener l)Removes the specified key listener so that it no longer receives key events from this component.public void removeKeyListener(KeyListener l)-
Description copied from class:
Component
Removes the specified key listener so that it no longer receives key events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the key listener- Since:
- JDK1.1
- See Also:
KeyEvent
,KeyListener
,Component.addKeyListener(java.awt.event.KeyListener)
,Component.getKeyListeners()
removeMouseListener void
removeMouseListener(MouseListener l)Removes the specified mouse listener so that it no longer receives mouse events from this component.public void removeMouseListener(MouseListener l)-
Description copied from class:
Component
Removes the specified mouse listener so that it no longer receives mouse events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the mouse listener- Since:
- JDK1.1
- See Also:
MouseEvent
,MouseListener
,Component.addMouseListener(java.awt.event.MouseListener)
,Component.getMouseListeners()
removeMouseMotionListener void
removeMouseMotionListener(MouseMotionListener l)Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component.public void removeMouseMotionListener(MouseMotionListener l)-
Description copied from class:
Component
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If listenerl
isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the mouse motion listener- Since:
- JDK1.1
- See Also:
MouseEvent
,MouseMotionListener
,Component.addMouseMotionListener(java.awt.event.MouseMotionListener)
,Component.getMouseMotionListeners()
removeMouseWheelListener void
removeMouseWheelListener(MouseWheelListener l)Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component.public void removeMouseWheelListener(MouseWheelListener l)-
Description copied from class:
Component
Removes the specified mouse wheel listener so that it no longer receives mouse wheel events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If l is null, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Parameters:
l
- the mouse wheel listener.- Since:
- 1.4
- See Also:
MouseWheelEvent
,MouseWheelListener
,Component.addMouseWheelListener(java.awt.event.MouseWheelListener)
,Component.getMouseWheelListeners()
removePropertyChangeListener void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)Removes a PropertyChangeListener from the listener list.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)-
Description copied from class:
Component
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.If listener is null, no exception is thrown and no action is performed.
- Parameters:
listener
- the PropertyChangeListener to be removed- See Also:
Component.addPropertyChangeListener(java.beans.PropertyChangeListener)
,Component.getPropertyChangeListeners()
,Component.removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)
removePropertyChangeListener void
removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Removes aPropertyChangeListener
from the listener list for a specific property.public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)-
Description copied from class:
Component
Removes aPropertyChangeListener
from the listener list for a specific property. This method should be used to removePropertyChangeListener
s that were registered for a specific bound property.If
propertyName
orlistener
isnull
, no exception is thrown and no action is taken.- Parameters:
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removed- See Also:
Component.addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,Component.getPropertyChangeListeners(java.lang.String)
,Component.removePropertyChangeListener(java.beans.PropertyChangeListener)
-
-
Keyboard Focus Methods Modifier and Type Method and Description areFocusTraversalKeysSet boolean
areFocusTraversalKeysSet(int id)Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container.public boolean areFocusTraversalKeysSet(int id)-
Returns whether the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Container. If this method returns
false
, this Container is inheriting the Set from an ancestor, or from the current KeyboardFocusManager.- Overrides:
areFocusTraversalKeysSet
in classComponent
- Parameters:
id
- one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS- Returns:
true
if the the Set of focus traversal keys for the given focus traversal operation has been explicitly defined for this Component;false
otherwise.- Throws:
java.lang.IllegalArgumentException
- if id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS- Since:
- 1.4
getFocusCycleRootAncestor Container
getFocusCycleRootAncestor()Returns the Container which is the focus cycle root of this Component's focus traversal cycle.public Container getFocusCycleRootAncestor()-
Description copied from class:
Component
Returns the Container which is the focus cycle root of this Component's focus traversal cycle. Each focus traversal cycle has only a single focus cycle root and each Component which is not a Container belongs to only a single focus traversal cycle. Containers which are focus cycle roots belong to two cycles: one rooted at the Container itself, and one rooted at the Container's nearest focus-cycle-root ancestor. For such Containers, this method will return the Container's nearest focus-cycle- root ancestor.- Returns:
- this Component's nearest focus-cycle-root ancestor
- Since:
- 1.4
- See Also:
isFocusCycleRoot()
getFocusTraversalKeys java.util.Set<AWTKeyStroke>
getFocusTraversalKeys(int id)Returns the Set of focus traversal keys for a given traversal operation for this Container.public java.util.Set<AWTKeyStroke> getFocusTraversalKeys(int id)-
Returns the Set of focus traversal keys for a given traversal operation for this Container. (See
setFocusTraversalKeys
for a full description of each key.)If a Set of traversal keys has not been explicitly defined for this Container, then this Container's parent's Set is returned. If no Set has been explicitly defined for any of this Container's ancestors, then the current KeyboardFocusManager's default Set is returned.
- Overrides:
getFocusTraversalKeys
in classComponent
- Parameters:
id
- one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS- Returns:
- the Set of AWTKeyStrokes for the specified operation. The Set will be unmodifiable, and may be empty. null will never be returned.
- Throws:
java.lang.IllegalArgumentException
- if id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS- Since:
- 1.4
- See Also:
setFocusTraversalKeys(int, java.util.Set<? extends java.awt.AWTKeyStroke>)
,KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
,KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
getFocusTraversalKeysEnabled boolean
getFocusTraversalKeysEnabled()Returns whether focus traversal keys are enabled for this Component.public boolean getFocusTraversalKeysEnabled()-
Description copied from class:
Component
Returns whether focus traversal keys are enabled for this Component. Components for which focus traversal keys are disabled receive key events for focus traversal keys. Components for which focus traversal keys are enabled do not see these events; instead, the events are automatically converted to traversal operations.- Returns:
- whether focus traversal keys are enabled for this Component
- Since:
- 1.4
- See Also:
Component.setFocusTraversalKeysEnabled(boolean)
,Component.setFocusTraversalKeys(int, java.util.Set<? extends java.awt.AWTKeyStroke>)
,Component.getFocusTraversalKeys(int)
getFocusTraversalPolicy FocusTraversalPolicy
getFocusTraversalPolicy()Returns the focus traversal policy that will manage keyboard traversal of this Container's children, or null if this Container is not a focus cycle root.public FocusTraversalPolicy getFocusTraversalPolicy()-
Returns the focus traversal policy that will manage keyboard traversal of this Container's children, or null if this Container is not a focus cycle root. If no traversal policy has been explicitly set for this Container, then this Container's focus-cycle-root ancestor's policy is returned.
- Returns:
- this Container's focus traversal policy, or null if this Container is not a focus cycle root.
- Since:
- 1.4
- See Also:
setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,setFocusCycleRoot(boolean)
,isFocusCycleRoot(java.awt.Container)
gotFocus boolean
gotFocus(Event evt, java.lang.Object what)Deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).Deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).hasFocus boolean
hasFocus()Returnstrue
if thisComponent
is the focus owner.public boolean hasFocus()-
Description copied from class:
Component
Returnstrue
if thisComponent
is the focus owner. This method is obsolete, and has been replaced byisFocusOwner()
.- Returns:
true
if thisComponent
is the focus owner;false
otherwise- Since:
- 1.2
isFocusable boolean
isFocusable()Returns whether this Component can be focused.public boolean isFocusable()-
Description copied from class:
Component
Returns whether this Component can be focused.- Returns:
true
if this Component is focusable;false
otherwise.- Since:
- 1.4
- See Also:
Component.setFocusable(boolean)
isFocusCycleRoot boolean
isFocusCycleRoot()Returns whether this Container is the root of a focus traversal cycle.public boolean isFocusCycleRoot()-
Returns whether this Container is the root of a focus traversal cycle. Once focus enters a traversal cycle, typically it cannot leave it via focus traversal unless one of the up- or down-cycle keys is pressed. Normal traversal is limited to this Container, and all of this Container's descendants that are not descendants of inferior focus cycle roots. Note that a FocusTraversalPolicy may bend these restrictions, however. For example, ContainerOrderFocusTraversalPolicy supports implicit down-cycle traversal.
- Returns:
- whether this Container is the root of a focus traversal cycle
- Since:
- 1.4
- See Also:
setFocusCycleRoot(boolean)
,setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,getFocusTraversalPolicy()
,ContainerOrderFocusTraversalPolicy
isFocusCycleRoot boolean
isFocusCycleRoot(Container container)Returns whether the specified Container is the focus cycle root of this Container's focus traversal cycle.public boolean isFocusCycleRoot(Container container)-
Returns whether the specified Container is the focus cycle root of this Container's focus traversal cycle. Each focus traversal cycle has only a single focus cycle root and each Container which is not a focus cycle root belongs to only a single focus traversal cycle. Containers which are focus cycle roots belong to two cycles: one rooted at the Container itself, and one rooted at the Container's nearest focus-cycle-root ancestor. This method will return
true
for both such Containers in this case.- Overrides:
isFocusCycleRoot
in classComponent
- Parameters:
container
- the Container to be tested- Returns:
true
if the specified Container is a focus-cycle- root of this Container;false
otherwise- Since:
- 1.4
- See Also:
isFocusCycleRoot()
isFocusOwner boolean
isFocusOwner()Returnstrue
if thisComponent
is the focus owner.public boolean isFocusOwner()-
Description copied from class:
Component
Returnstrue
if thisComponent
is the focus owner.- Returns:
true
if thisComponent
is the focus owner;false
otherwise- Since:
- 1.4
isFocusTraversable boolean
isFocusTraversable()Deprecated. As of 1.4, replaced byisFocusable()
.@Deprecated public boolean isFocusTraversable()Deprecated. As of 1.4, replaced byisFocusable()
.-
Description copied from class:
Component
Returns whether thisComponent
can become the focus owner.- Returns:
true
if thisComponent
is focusable;false
otherwise- Since:
- JDK1.1
- See Also:
Component.setFocusable(boolean)
isFocusTraversalPolicyProvider boolean
isFocusTraversalPolicyProvider()Returns whether this container provides focus traversal policy.public final boolean isFocusTraversalPolicyProvider()-
Returns whether this container provides focus traversal policy. If this property is set to
true
then when keyboard focus manager searches container hierarchy for focus traversal policy and encounters this container before any other container with this property as true or focus cycle roots then its focus traversal policy will be used instead of focus cycle root's policy.- Returns:
true
if this container provides focus traversal policy,false
otherwise- Since:
- 1.5
- See Also:
setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,getFocusTraversalPolicy()
,setFocusCycleRoot(boolean)
,setFocusTraversalPolicyProvider(boolean)
isFocusTraversalPolicySet boolean
isFocusTraversalPolicySet()Returns whether the focus traversal policy has been explicitly set for this Container.public boolean isFocusTraversalPolicySet()-
Returns whether the focus traversal policy has been explicitly set for this Container. If this method returns
false
, this Container will inherit its focus traversal policy from an ancestor.- Returns:
true
if the focus traversal policy has been explicitly set for this Container;false
otherwise.- Since:
- 1.4
lostFocus boolean
lostFocus(Event evt, java.lang.Object what)Deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).Deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).nextFocus void
nextFocus()Deprecated. As of JDK version 1.1, replaced by transferFocus().@Deprecated public void nextFocus()Deprecated. As of JDK version 1.1, replaced by transferFocus().requestFocus void
requestFocus()Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.public void requestFocus()-
Description copied from class:
Component
Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window. This component must be displayable, focusable, visible and all of its ancestors (with the exception of the top-level Window) must be visible for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event. If this request is denied because this Component's top-level Window cannot become the focused Window, the request will be remembered and will be granted when the Window is later focused by the user.This method cannot be used to set the focus owner to no Component at all. Use
KeyboardFocusManager.clearGlobalFocusOwner()
instead.Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use
requestFocusInWindow
when possible.Note: Not all focus transfers result from invoking this method. As such, a component may receive focus without this or any of the other
requestFocus
methods ofComponent
being invoked.
requestFocus protected boolean
requestFocus(boolean temporary)Requests that thisComponent
get the input focus, and that thisComponent
's top-level ancestor become the focusedWindow
.protected boolean requestFocus(boolean temporary)-
Description copied from class:
Component
Requests that thisComponent
get the input focus, and that thisComponent
's top-level ancestor become the focusedWindow
. This component must be displayable, focusable, visible and all of its ancestors (with the exception of the top-level Window) must be visible for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this component is the focus owner until this component receives a FOCUS_GAINED event. If this request is denied because this component's top-level window cannot become the focused window, the request will be remembered and will be granted when the window is later focused by the user.This method returns a boolean value. If
false
is returned, the request is guaranteed to fail. Iftrue
is returned, the request will succeed unless it is vetoed, or an extraordinary event, such as disposal of the component's peer, occurs before the request can be granted by the native windowing system. Again, while a return value oftrue
indicates that the request is likely to succeed, developers must never assume that this component is the focus owner until this component receives a FOCUS_GAINED event.This method cannot be used to set the focus owner to no component at all. Use
KeyboardFocusManager.clearGlobalFocusOwner
instead.Because the focus behavior of this method is platform-dependent, developers are strongly encouraged to use
requestFocusInWindow
when possible.Every effort will be made to ensure that
FocusEvent
s generated as a result of this request will have the specified temporary value. However, because specifying an arbitrary temporary state may not be implementable on all native windowing systems, correct behavior for this method can be guaranteed only for lightweightComponent
s. This method is not intended for general use, but exists instead as a hook for lightweight component libraries, such as Swing.Note: Not all focus transfers result from invoking this method. As such, a component may receive focus without this or any of the other
requestFocus
methods ofComponent
being invoked.- Parameters:
temporary
- true if the focus change is temporary, such as when the window loses the focus; for more information on temporary focus changes see the Focus Specification- Returns:
false
if the focus change request is guaranteed to fail;true
if it is likely to succeed- Since:
- 1.4
- See Also:
FocusEvent
,Component.addFocusListener(java.awt.event.FocusListener)
,Component.isFocusable()
,Component.isDisplayable()
,KeyboardFocusManager.clearGlobalFocusOwner()
requestFocusInWindow boolean
requestFocusInWindow()Requests that this Component get the input focus, if this Component's top-level ancestor is already the focused Window.public boolean requestFocusInWindow()-
Description copied from class:
Component
Requests that this Component get the input focus, if this Component's top-level ancestor is already the focused Window. This component must be displayable, focusable, visible and all of its ancestors (with the exception of the top-level Window) must be visible for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.This method returns a boolean value. If
false
is returned, the request is guaranteed to fail. Iftrue
is returned, the request will succeed unless it is vetoed, or an extraordinary event, such as disposal of the Component's peer, occurs before the request can be granted by the native windowing system. Again, while a return value oftrue
indicates that the request is likely to succeed, developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.This method cannot be used to set the focus owner to no Component at all. Use
KeyboardFocusManager.clearGlobalFocusOwner()
instead.The focus behavior of this method can be implemented uniformly across platforms, and thus developers are strongly encouraged to use this method over
requestFocus
when possible. Code which relies onrequestFocus
may exhibit different focus behavior on different platforms.Note: Not all focus transfers result from invoking this method. As such, a component may receive focus without this or any of the other
requestFocus
methods ofComponent
being invoked.- Returns:
false
if the focus change request is guaranteed to fail;true
if it is likely to succeed- Since:
- 1.4
- See Also:
Component.requestFocus()
,FocusEvent
,Component.addFocusListener(java.awt.event.FocusListener)
,Component.isFocusable()
,Component.isDisplayable()
,KeyboardFocusManager.clearGlobalFocusOwner()
requestFocusInWindow protected boolean
requestFocusInWindow(boolean temporary)Requests that thisComponent
get the input focus, if thisComponent
's top-level ancestor is already the focusedWindow
.protected boolean requestFocusInWindow(boolean temporary)-
Description copied from class:
Component
Requests that thisComponent
get the input focus, if thisComponent
's top-level ancestor is already the focusedWindow
. This component must be displayable, focusable, visible and all of its ancestors (with the exception of the top-level Window) must be visible for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this component is the focus owner until this component receives a FOCUS_GAINED event.This method returns a boolean value. If
false
is returned, the request is guaranteed to fail. Iftrue
is returned, the request will succeed unless it is vetoed, or an extraordinary event, such as disposal of the component's peer, occurs before the request can be granted by the native windowing system. Again, while a return value oftrue
indicates that the request is likely to succeed, developers must never assume that this component is the focus owner until this component receives a FOCUS_GAINED event.This method cannot be used to set the focus owner to no component at all. Use
KeyboardFocusManager.clearGlobalFocusOwner
instead.The focus behavior of this method can be implemented uniformly across platforms, and thus developers are strongly encouraged to use this method over
requestFocus
when possible. Code which relies onrequestFocus
may exhibit different focus behavior on different platforms.Every effort will be made to ensure that
FocusEvent
s generated as a result of this request will have the specified temporary value. However, because specifying an arbitrary temporary state may not be implementable on all native windowing systems, correct behavior for this method can be guaranteed only for lightweight components. This method is not intended for general use, but exists instead as a hook for lightweight component libraries, such as Swing.Note: Not all focus transfers result from invoking this method. As such, a component may receive focus without this or any of the other
requestFocus
methods ofComponent
being invoked.- Parameters:
temporary
- true if the focus change is temporary, such as when the window loses the focus; for more information on temporary focus changes see the Focus Specification- Returns:
false
if the focus change request is guaranteed to fail;true
if it is likely to succeed- Since:
- 1.4
- See Also:
Component.requestFocus()
,FocusEvent
,Component.addFocusListener(java.awt.event.FocusListener)
,Component.isFocusable()
,Component.isDisplayable()
,KeyboardFocusManager.clearGlobalFocusOwner()
setFocusable void
setFocusable(boolean focusable)Sets the focusable state of this Component to the specified value.public void setFocusable(boolean focusable)-
Description copied from class:
Component
Sets the focusable state of this Component to the specified value. This value overrides the Component's default focusability.- Parameters:
focusable
- indicates whether this Component is focusable- Since:
- 1.4
- See Also:
Component.isFocusable()
setFocusCycleRoot void
setFocusCycleRoot(boolean focusCycleRoot)Sets whether this Container is the root of a focus traversal cycle.public void setFocusCycleRoot(boolean focusCycleRoot)-
Sets whether this Container is the root of a focus traversal cycle. Once focus enters a traversal cycle, typically it cannot leave it via focus traversal unless one of the up- or down-cycle keys is pressed. Normal traversal is limited to this Container, and all of this Container's descendants that are not descendants of inferior focus cycle roots. Note that a FocusTraversalPolicy may bend these restrictions, however. For example, ContainerOrderFocusTraversalPolicy supports implicit down-cycle traversal.
The alternative way to specify the traversal order of this Container's children is to make this Container a focus traversal policy provider.
- Parameters:
focusCycleRoot
- indicates whether this Container is the root of a focus traversal cycle- Since:
- 1.4
- See Also:
isFocusCycleRoot()
,setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,getFocusTraversalPolicy()
,ContainerOrderFocusTraversalPolicy
,setFocusTraversalPolicyProvider(boolean)
setFocusTraversalKeys void
setFocusTraversalKeys(int id, java.util.Set<? extends AWTKeyStroke> keystrokes)Sets the focus traversal keys for a given traversal operation for this Container.public void setFocusTraversalKeys(int id, java.util.Set<? extends AWTKeyStroke> keystrokes)-
Sets the focus traversal keys for a given traversal operation for this Container.
The default values for a Container's focus traversal keys are implementation-dependent. Sun recommends that all implementations for a particular native platform use the same default values. The recommendations for Windows and Unix are listed below. These recommendations are used in the Sun AWT implementations.
Identifier Meaning Default KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS Normal forward keyboard traversal TAB on KEY_PRESSED, CTRL-TAB on KEY_PRESSED KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS Normal reverse keyboard traversal SHIFT-TAB on KEY_PRESSED, CTRL-SHIFT-TAB on KEY_PRESSED KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS Go up one focus traversal cycle none KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS Go down one focus traversal cycle none Using the AWTKeyStroke API, client code can specify on which of two specific KeyEvents, KEY_PRESSED or KEY_RELEASED, the focus traversal operation will occur. Regardless of which KeyEvent is specified, however, all KeyEvents related to the focus traversal key, including the associated KEY_TYPED event, will be consumed, and will not be dispatched to any Container. It is a runtime error to specify a KEY_TYPED event as mapping to a focus traversal operation, or to map the same event to multiple default focus traversal operations.
If a value of null is specified for the Set, this Container inherits the Set from its parent. If all ancestors of this Container have null specified for the Set, then the current KeyboardFocusManager's default Set is used.
- Overrides:
setFocusTraversalKeys
in classComponent
- Parameters:
id
- one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYSkeystrokes
- the Set of AWTKeyStroke for the specified operation- Throws:
java.lang.IllegalArgumentException
- if id is not one of KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS, or KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS, or if keystrokes contains null, or if any Object in keystrokes is not an AWTKeyStroke, or if any keystroke represents a KEY_TYPED event, or if any keystroke already maps to another focus traversal operation for this Container- Since:
- 1.4
- See Also:
getFocusTraversalKeys(int)
,KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS
,KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS
,KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS
,KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
setFocusTraversalKeysEnabled void
setFocusTraversalKeysEnabled(boolean focusTraversalKeysEnabled)Sets whether focus traversal keys are enabled for this Component.public void setFocusTraversalKeysEnabled(boolean focusTraversalKeysEnabled)-
Description copied from class:
Component
Sets whether focus traversal keys are enabled for this Component. Components for which focus traversal keys are disabled receive key events for focus traversal keys. Components for which focus traversal keys are enabled do not see these events; instead, the events are automatically converted to traversal operations.- Parameters:
focusTraversalKeysEnabled
- whether focus traversal keys are enabled for this Component- Since:
- 1.4
- See Also:
Component.getFocusTraversalKeysEnabled()
,Component.setFocusTraversalKeys(int, java.util.Set<? extends java.awt.AWTKeyStroke>)
,Component.getFocusTraversalKeys(int)
setFocusTraversalPolicy void
setFocusTraversalPolicy(FocusTraversalPolicy policy)Sets the focus traversal policy that will manage keyboard traversal of this Container's children, if this Container is a focus cycle root.public void setFocusTraversalPolicy(FocusTraversalPolicy policy)-
Sets the focus traversal policy that will manage keyboard traversal of this Container's children, if this Container is a focus cycle root. If the argument is null, this Container inherits its policy from its focus- cycle-root ancestor. If the argument is non-null, this policy will be inherited by all focus-cycle-root children that have no keyboard- traversal policy of their own (as will, recursively, their focus-cycle- root children).
If this Container is not a focus cycle root, the policy will be remembered, but will not be used or inherited by this or any other Containers until this Container is made a focus cycle root.
- Parameters:
policy
- the new focus traversal policy for this Container- Since:
- 1.4
- See Also:
getFocusTraversalPolicy()
,setFocusCycleRoot(boolean)
,isFocusCycleRoot(java.awt.Container)
setFocusTraversalPolicyProvider void
setFocusTraversalPolicyProvider(boolean provider)Sets whether this container will be used to provide focus traversal policy.public final void setFocusTraversalPolicyProvider(boolean provider)-
Sets whether this container will be used to provide focus traversal policy. Container with this property as
true
will be used to acquire focus traversal policy instead of closest focus cycle root ancestor.- Parameters:
provider
- indicates whether this container will be used to provide focus traversal policy- Since:
- 1.5
- See Also:
setFocusTraversalPolicy(java.awt.FocusTraversalPolicy)
,getFocusTraversalPolicy()
,isFocusTraversalPolicyProvider()
transferFocus void
transferFocus()Transfers the focus to the next component, as though this Component were the focus owner.public void transferFocus()-
Description copied from class:
Component
Transfers the focus to the next component, as though this Component were the focus owner.- Since:
- JDK1.1
- See Also:
Component.requestFocus()
transferFocusBackward void
transferFocusBackward()Transfers the focus to the previous component, as though this Component were the focus owner.public void transferFocusBackward()-
Description copied from class:
Component
Transfers the focus to the previous component, as though this Component were the focus owner.- Since:
- 1.4
- See Also:
Component.requestFocus()
transferFocusDownCycle void
transferFocusDownCycle()Transfers the focus down one focus traversal cycle.public void transferFocusDownCycle()-
Transfers the focus down one focus traversal cycle. If this Container is a focus cycle root, then the focus owner is set to this Container's default Component to focus, and the current focus cycle root is set to this Container. If this Container is not a focus cycle root, then no focus traversal operation occurs.
- Since:
- 1.4
- See Also:
Component.requestFocus()
,isFocusCycleRoot(java.awt.Container)
,setFocusCycleRoot(boolean)
transferFocusUpCycle void
transferFocusUpCycle()Transfers the focus up one focus traversal cycle.public void transferFocusUpCycle()-
Description copied from class:
Component
Transfers the focus up one focus traversal cycle. Typically, the focus owner is set to this Component's focus cycle root, and the current focus cycle root is set to the new focus owner's focus cycle root. If, however, this Component's focus cycle root is a Window, then the focus owner is set to the focus cycle root's default Component to focus, and the current focus cycle root is unchanged.- Since:
- 1.4
- See Also:
Component.requestFocus()
,isFocusCycleRoot()
,setFocusCycleRoot(boolean)
-
-
Graphics Methods Modifier and Type Method and Description getFontMetrics FontMetrics
getFontMetrics(Font font)Gets the font metrics for the specified font.-
Description copied from class:
Component
Gets the font metrics for the specified font. Warning: Since Font metrics are affected by theFontRenderContext
and this method does not provide one, it can return only metrics for the default render context which may not match that used when rendering on the Component ifGraphics2D
functionality is being used. Instead metrics can be obtained at rendering time by callingGraphics.getFontMetrics()
or text measurement APIs on theFont
class.- Parameters:
font
- the font for which font metrics is to be obtained- Returns:
- the font metrics for
font
- Since:
- JDK1.0
- See Also:
Component.getFont()
,Component.getPeer()
,ComponentPeer.getFontMetrics(Font)
,Toolkit.getFontMetrics(Font)
getGraphics Graphics
getGraphics()Creates a graphics context for this component.public Graphics getGraphics()-
Description copied from class:
Component
Creates a graphics context for this component. This method will returnnull
if this component is currently not displayable.- Returns:
- a graphics context for this component, or
null
if it has none - Since:
- JDK1.0
- See Also:
Component.paint(java.awt.Graphics)
getGraphicsConfiguration GraphicsConfiguration
getGraphicsConfiguration()Gets theGraphicsConfiguration
associated with thisComponent
.public GraphicsConfiguration getGraphicsConfiguration()-
Description copied from class:
Component
Gets theGraphicsConfiguration
associated with thisComponent
. If theComponent
has not been assigned a specificGraphicsConfiguration
, theGraphicsConfiguration
of theComponent
object's top-level container is returned. If theComponent
has been created, but not yet added to aContainer
, this method returnsnull
.- Returns:
- the
GraphicsConfiguration
used by thisComponent
ornull
- Since:
- 1.3
getLocationOnScreen Point
getLocationOnScreen()Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.public Point getLocationOnScreen()-
Description copied from class:
Component
Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.- Returns:
- an instance of
Point
representing the top-left corner of the component's bounds in the coordinate space of the screen - Throws:
- if the component is not showing on the screenIllegalComponentStateException
- See Also:
Component.setLocation(int, int)
,Component.getLocation()
getMousePosition Point
getMousePosition()Returns the position of the mouse pointer in thisComponent
's coordinate space if theComponent
is directly under the mouse pointer, otherwise returnsnull
.-
Description copied from class:
Component
Returns the position of the mouse pointer in thisComponent
's coordinate space if theComponent
is directly under the mouse pointer, otherwise returnsnull
. If theComponent
is not showing on the screen, this method returnsnull
even if the mouse pointer is above the area where theComponent
would be displayed. If theComponent
is partially or fully obscured by otherComponent
s or native windows, this method returns a non-null value only if the mouse pointer is located above the unobscured part of theComponent
.For
Container
s it returns a non-null value if the mouse is above theContainer
itself or above any of its descendants. UsegetMousePosition(boolean)
if you need to exclude children.Sometimes the exact mouse coordinates are not important, and the only thing that matters is whether a specific
Component
is under the mouse pointer. If the return value of this method isnull
, mouse pointer is not directly above theComponent
.- Returns:
- mouse coordinates relative to this
Component
, or null - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.5
- See Also:
Component.isShowing()
,getMousePosition(boolean)
getToolkit Toolkit
getToolkit()Gets the toolkit of this component.public Toolkit getToolkit()-
Description copied from class:
Component
Gets the toolkit of this component. Note that the frame that contains a component controls which toolkit is used by that component. Therefore if the component is moved from one frame to another, the toolkit it uses may change.- Returns:
- the toolkit of this component
- Since:
- JDK1.0
-
-
Hierarchy Methods Modifier and Type Method and Description add Component
add(Component comp)Appends the specified component to the end of this container.-
Appends the specified component to the end of this container. This is a convenience method for
addImpl(java.awt.Component, java.lang.Object, int)
.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
- Parameters:
comp
- the component to be added- Returns:
- the component argument
- Throws:
java.lang.NullPointerException
- ifcomp
isnull
- See Also:
addImpl(java.awt.Component, java.lang.Object, int)
,invalidate()
,validate()
,JComponent.revalidate()
add Component
add(Component comp, int index)Adds the specified component to this container at the given position.-
Adds the specified component to this container at the given position. This is a convenience method for
addImpl(java.awt.Component, java.lang.Object, int)
.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
- Parameters:
comp
- the component to be addedindex
- the position at which to insert the component, or-1
to append the component to the end- Returns:
- the component
comp
- Throws:
java.lang.NullPointerException
- ifcomp
isnull
java.lang.IllegalArgumentException
- ifindex
is invalid (seeaddImpl(java.awt.Component, java.lang.Object, int)
for details)- See Also:
addImpl(java.awt.Component, java.lang.Object, int)
,remove(int)
,invalidate()
,validate()
,JComponent.revalidate()
add void
add(Component comp, java.lang.Object constraints)Adds the specified component to the end of this container.public void add(Component comp, java.lang.Object constraints)-
Adds the specified component to the end of this container. Also notifies the layout manager to add the component to this container's layout using the specified constraints object. This is a convenience method for
addImpl(java.awt.Component, java.lang.Object, int)
.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
- Parameters:
comp
- the component to be addedconstraints
- an object expressing layout contraints for this component- Throws:
java.lang.NullPointerException
- ifcomp
isnull
- Since:
- JDK1.1
- See Also:
addImpl(java.awt.Component, java.lang.Object, int)
,invalidate()
,validate()
,JComponent.revalidate()
,LayoutManager
add void
add(Component comp, java.lang.Object constraints, int index)Adds the specified component to this container with the specified constraints at the specified index.public void add(Component comp, java.lang.Object constraints, int index)-
Adds the specified component to this container with the specified constraints at the specified index. Also notifies the layout manager to add the component to the this container's layout using the specified constraints object. This is a convenience method for
addImpl(java.awt.Component, java.lang.Object, int)
.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
- Parameters:
comp
- the component to be addedconstraints
- an object expressing layout contraints for thisindex
- the position in the container's list at which to insert the component;-1
means insert at the end component- Throws:
java.lang.NullPointerException
- ifcomp
isnull
java.lang.IllegalArgumentException
- ifindex
is invalid (seeaddImpl(java.awt.Component, java.lang.Object, int)
for details)- See Also:
addImpl(java.awt.Component, java.lang.Object, int)
,invalidate()
,validate()
,JComponent.revalidate()
,remove(int)
,LayoutManager
add Component
add(java.lang.String name, Component comp)Adds the specified component to this container.-
Adds the specified component to this container. This is a convenience method for
addImpl(java.awt.Component, java.lang.Object, int)
.This method is obsolete as of 1.1. Please use the method
add(Component, Object)
instead.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
- Throws:
java.lang.NullPointerException
- ifcomp
isnull
- See Also:
add(Component, Object)
,invalidate()
addImpl protected void
addImpl(Component comp, java.lang.Object constraints, int index)Adds the specified component to this container at the specified index.protected void addImpl(Component comp, java.lang.Object constraints, int index)-
Adds the specified component to this container at the specified index. This method also notifies the layout manager to add the component to this container's layout using the specified constraints object via the
addLayoutComponent
method.The constraints are defined by the particular layout manager being used. For example, the
BorderLayout
class defines five constraints:BorderLayout.NORTH
,BorderLayout.SOUTH
,BorderLayout.EAST
,BorderLayout.WEST
, andBorderLayout.CENTER
.The
GridBagLayout
class requires aGridBagConstraints
object. Failure to pass the correct type of constraints object results in anIllegalArgumentException
.If the current layout manager implements
LayoutManager2
, thenLayoutManager2.addLayoutComponent(Component,Object)
is invoked on it. If the current layout manager does not implementLayoutManager2
, and constraints is aString
, thenLayoutManager.addLayoutComponent(String,Component)
is invoked on it.If the component is not an ancestor of this container and has a non-null parent, it is removed from its current parent before it is added to this container.
This is the method to override if a program needs to track every add request to a container as all other add methods defer to this one. An overriding method should usually include a call to the superclass's version of the method:
super.addImpl(comp, constraints, index)
This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
- Parameters:
comp
- the component to be addedconstraints
- an object expressing layout constraints for this componentindex
- the position in the container's list at which to insert the component, where-1
means append to the end- Throws:
java.lang.IllegalArgumentException
- ifindex
is invalid; ifcomp
is a child of this container, the valid range is[-1, getComponentCount()-1]
; if component is not a child of this container, the valid range is[-1, getComponentCount()]
java.lang.IllegalArgumentException
- ifcomp
is an ancestor of this containerjava.lang.IllegalArgumentException
- if adding a window to a containerjava.lang.NullPointerException
- ifcomp
isnull
- Since:
- JDK1.1
- See Also:
add(Component)
,add(Component, int)
,add(Component, java.lang.Object)
,invalidate()
,LayoutManager
,LayoutManager2
countComponents int
countComponents()Deprecated. As of JDK version 1.1, replaced by getComponentCount().@Deprecated public int countComponents()Deprecated. As of JDK version 1.1, replaced by getComponentCount().getComponent Component
getComponent(int n)Gets the nth component in this container.public Component getComponent(int n)-
Gets the nth component in this container.
Note: This method should be called under AWT tree lock.
- Parameters:
n
- the index of the component to get.- Returns:
- the nth component in this container.
- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the nth value does not exist.- See Also:
Component.getTreeLock()
getComponentCount int
getComponentCount()Gets the number of components in this panel.public int getComponentCount()-
Gets the number of components in this panel.
Note: This method should be called under AWT tree lock.
- Returns:
- the number of components in this panel.
- Since:
- JDK1.1
- See Also:
getComponent(int)
,Component.getTreeLock()
getComponents Component[]
getComponents()Gets all the components in this container.public Component[] getComponents()-
Gets all the components in this container.
Note: This method should be called under AWT tree lock.
- Returns:
- an array of all the components in this container.
- See Also:
Component.getTreeLock()
getComponentZOrder int
getComponentZOrder(Component comp)Returns the z-order index of the component inside the container.public int getComponentZOrder(Component comp)-
Returns the z-order index of the component inside the container. The higher a component is in the z-order hierarchy, the lower its index. The component with the lowest z-order index is painted last, above all other child components.
- Parameters:
comp
- the component being queried- Returns:
- the z-order index of the component; otherwise
returns -1 if the component is
null
or doesn't belong to the container - Since:
- 1.5
- See Also:
setComponentZOrder(java.awt.Component, int)
isAncestorOf boolean
isAncestorOf(Component c)Checks if the component is contained in the component hierarchy of this container.public boolean isAncestorOf(Component c)-
Checks if the component is contained in the component hierarchy of this container.
- Parameters:
c
- the component- Returns:
true
if it is an ancestor;false
otherwise.- Since:
- JDK1.1
remove void
remove(Component comp)Removes the specified component from this container.public void remove(Component comp)-
Removes the specified component from this container. This method also notifies the layout manager to remove the component from this container's layout via the
removeLayoutComponent
method.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to reflect the changes.
- Parameters:
comp
- the component to be removed- Throws:
java.lang.NullPointerException
- ifcomp
isnull
- See Also:
add(java.awt.Component)
,invalidate()
,validate()
,remove(int)
remove void
remove(int index)Removes the component, specified byindex
, from this container.public void remove(int index)-
Removes the component, specified by
index
, from this container. This method also notifies the layout manager to remove the component from this container's layout via theremoveLayoutComponent
method.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to reflect the changes.
- Parameters:
index
- the index of the component to be removed- Throws:
java.lang.ArrayIndexOutOfBoundsException
- ifindex
is not in range[0, getComponentCount()-1]
- Since:
- JDK1.1
- See Also:
add(java.awt.Component)
,invalidate()
,validate()
,getComponentCount()
removeAll void
removeAll()Removes all the components from this container.public void removeAll()-
Removes all the components from this container. This method also notifies the layout manager to remove the components from this container's layout via the
removeLayoutComponent
method.This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to reflect the changes.
- See Also:
add(java.awt.Component)
,remove(int)
,invalidate()
setComponentZOrder void
setComponentZOrder(Component comp, int index)Moves the specified component to the specified z-order index in the container.public void setComponentZOrder(Component comp, int index)-
Moves the specified component to the specified z-order index in the container. The z-order determines the order that components are painted; the component with the highest z-order paints first and the component with the lowest z-order paints last. Where components overlap, the component with the lower z-order paints over the component with the higher z-order.
If the component is a child of some other container, it is removed from that container before being added to this container. The important difference between this method and
java.awt.Container.add(Component, int)
is that this method doesn't callremoveNotify
on the component while removing it from its previous container unless necessary and when allowed by the underlying native windowing system. This way, if the component has the keyboard focus, it maintains the focus when moved to the new position.This property is guaranteed to apply only to lightweight non-
Container
components.This method changes layout-related information, and therefore, invalidates the component hierarchy.
Note: Not all platforms support changing the z-order of heavyweight components from one container into another without the call to
removeNotify
. There is no way to detect whether a platform supports this, so developers shouldn't make any assumptions.- Parameters:
comp
- the component to be movedindex
- the position in the container's list to insert the component, wheregetComponentCount()
appends to the end- Throws:
java.lang.NullPointerException
- ifcomp
isnull
java.lang.IllegalArgumentException
- ifcomp
is one of the container's parentsjava.lang.IllegalArgumentException
- ifindex
is not in the range[0, getComponentCount()]
for moving between containers, or not in the range[0, getComponentCount()-1]
for moving inside a containerjava.lang.IllegalArgumentException
- if adding a container to itselfjava.lang.IllegalArgumentException
- if adding aWindow
to a container- Since:
- 1.5
- See Also:
getComponentZOrder(java.awt.Component)
,invalidate()
-
-
Image Methods Modifier and Type Method and Description checkImage int
checkImage(Image image, java.awt.image.ImageObserver observer)Returns the status of the construction of a screen representation of the specified image.public int checkImage(Image image, java.awt.image.ImageObserver observer)-
Description copied from class:
Component
Returns the status of the construction of a screen representation of the specified image.This method does not cause the image to begin loading. An application must use the
prepareImage
method to force the loading of an image.Information on the flags returned by this method can be found with the discussion of the
ImageObserver
interface.- Parameters:
image
- theImage
object whose status is being checkedobserver
- theImageObserver
object to be notified as the image is being prepared- Returns:
- the bitwise inclusive OR of
ImageObserver
flags indicating what information about the image is currently available - Since:
- JDK1.0
- See Also:
Component.prepareImage(Image, int, int, java.awt.image.ImageObserver)
,Toolkit.checkImage(Image, int, int, java.awt.image.ImageObserver)
,ImageObserver
checkImage int
checkImage(Image image, int width, int height, java.awt.image.ImageObserver observer)Returns the status of the construction of a screen representation of the specified image.public int checkImage(Image image, int width, int height, java.awt.image.ImageObserver observer)-
Description copied from class:
Component
Returns the status of the construction of a screen representation of the specified image.This method does not cause the image to begin loading. An application must use the
prepareImage
method to force the loading of an image.The
checkImage
method ofComponent
calls its peer'scheckImage
method to calculate the flags. If this component does not yet have a peer, the component's toolkit'scheckImage
method is called instead.Information on the flags returned by this method can be found with the discussion of the
ImageObserver
interface.- Parameters:
image
- theImage
object whose status is being checkedwidth
- the width of the scaled version whose status is to be checkedheight
- the height of the scaled version whose status is to be checkedobserver
- theImageObserver
object to be notified as the image is being prepared- Returns:
- the bitwise inclusive OR of
ImageObserver
flags indicating what information about the image is currently available - Since:
- JDK1.0
- See Also:
Component.prepareImage(Image, int, int, java.awt.image.ImageObserver)
,Toolkit.checkImage(Image, int, int, java.awt.image.ImageObserver)
,ImageObserver
createImage Image
createImage(java.awt.image.ImageProducer producer)Creates an image from the specified image producer.createImage Image
createImage(int width, int height)Creates an off-screen drawable image to be used for double buffering.public Image createImage(int width, int height)-
Description copied from class:
Component
Creates an off-screen drawable image to be used for double buffering.- Parameters:
width
- the specified widthheight
- the specified height- Returns:
- an off-screen drawable image, which can be used for double
buffering. The return value may be
null
if the component is not displayable. This will always happen ifGraphicsEnvironment.isHeadless()
returnstrue
. - Since:
- JDK1.0
- See Also:
Component.isDisplayable()
,GraphicsEnvironment.isHeadless()
createVolatileImage java.awt.image.VolatileImage
createVolatileImage(int width, int height)Creates a volatile off-screen drawable image to be used for double buffering.public java.awt.image.VolatileImage createVolatileImage(int width, int height)-
Description copied from class:
Component
Creates a volatile off-screen drawable image to be used for double buffering.- Parameters:
width
- the specified width.height
- the specified height.- Returns:
- an off-screen drawable image, which can be used for double
buffering. The return value may be
null
if the component is not displayable. This will always happen ifGraphicsEnvironment.isHeadless()
returnstrue
. - Since:
- 1.4
- See Also:
VolatileImage
,Component.isDisplayable()
,GraphicsEnvironment.isHeadless()
createVolatileImage java.awt.image.VolatileImage
createVolatileImage(int width, int height, ImageCapabilities caps)Creates a volatile off-screen drawable image, with the given capabilities.public java.awt.image.VolatileImage createVolatileImage(int width, int height, ImageCapabilities caps) throws AWTException-
Description copied from class:
Component
Creates a volatile off-screen drawable image, with the given capabilities. The contents of this image may be lost at any time due to operating system issues, so the image must be managed via theVolatileImage
interface.- Parameters:
width
- the specified width.height
- the specified height.caps
- the image capabilities- Returns:
- a VolatileImage object, which can be used to manage surface contents loss and capabilities.
- Throws:
AWTException
- if an image with the specified capabilities cannot be created- Since:
- 1.4
- See Also:
VolatileImage
imageUpdate boolean
imageUpdate(Image img, int infoflags, int x, int y, int w, int h)Repaints the component when the image has changed.public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)-
Description copied from class:
Component
Repaints the component when the image has changed. ThisimageUpdate
method of anImageObserver
is called when more information about an image which had been previously requested using an asynchronous routine such as thedrawImage
method ofGraphics
becomes available. See the definition ofimageUpdate
for more information on this method and its arguments.The
imageUpdate
method ofComponent
incrementally draws an image on the component as more of the bits of the image are available.If the system property
awt.image.incrementaldraw
is missing or has the valuetrue
, the image is incrementally drawn. If the system property has any other value, then the image is not drawn until it has been completely loaded.Also, if incremental drawing is in effect, the value of the system property
awt.image.redrawrate
is interpreted as an integer to give the maximum redraw rate, in milliseconds. If the system property is missing or cannot be interpreted as an integer, the redraw rate is once every 100ms.The interpretation of the
x
,y
,width
, andheight
arguments depends on the value of theinfoflags
argument.- Specified by:
imageUpdate
in interfacejava.awt.image.ImageObserver
- Parameters:
img
- the image being observedinfoflags
- seeimageUpdate
for more informationx
- the x coordinatey
- the y coordinatew
- the widthh
- the height- Returns:
false
if the infoflags indicate that the image is completely loaded;true
otherwise.- Since:
- JDK1.0
- See Also:
ImageObserver
,Graphics.drawImage(Image, int, int, Color, java.awt.image.ImageObserver)
,Graphics.drawImage(Image, int, int, java.awt.image.ImageObserver)
,Graphics.drawImage(Image, int, int, int, int, Color, java.awt.image.ImageObserver)
,Graphics.drawImage(Image, int, int, int, int, java.awt.image.ImageObserver)
,ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
prepareImage boolean
prepareImage(Image image, java.awt.image.ImageObserver observer)Prepares an image for rendering on this component.public boolean prepareImage(Image image, java.awt.image.ImageObserver observer)-
Description copied from class:
Component
Prepares an image for rendering on this component. The image data is downloaded asynchronously in another thread and the appropriate screen representation of the image is generated.- Parameters:
image
- theImage
for which to prepare a screen representationobserver
- theImageObserver
object to be notified as the image is being prepared- Returns:
true
if the image has already been fully prepared;false
otherwise- Since:
- JDK1.0
prepareImage boolean
prepareImage(Image image, int width, int height, java.awt.image.ImageObserver observer)Prepares an image for rendering on this component at the specified width and height.public boolean prepareImage(Image image, int width, int height, java.awt.image.ImageObserver observer)-
Description copied from class:
Component
Prepares an image for rendering on this component at the specified width and height.The image data is downloaded asynchronously in another thread, and an appropriately scaled screen representation of the image is generated.
- Parameters:
image
- the instance ofImage
for which to prepare a screen representationwidth
- the width of the desired screen representationheight
- the height of the desired screen representationobserver
- theImageObserver
object to be notified as the image is being prepared- Returns:
true
if the image has already been fully prepared;false
otherwise- Since:
- JDK1.0
- See Also:
ImageObserver
-
-
Layout Methods Modifier and Type Method and Description bounds Rectangle
bounds()Deprecated. As of JDK version 1.1, replaced bygetBounds()
.contains boolean
contains(int x, int y)Checks whether this component "contains" the specified point, wherex
andy
are defined to be relative to the coordinate system of this component.public boolean contains(int x, int y)-
Description copied from class:
Component
Checks whether this component "contains" the specified point, wherex
andy
are defined to be relative to the coordinate system of this component.- Parameters:
x
- the x coordinate of the pointy
- the y coordinate of the point- Since:
- JDK1.1
- See Also:
Component.getComponentAt(int, int)
contains boolean
contains(Point p)Checks whether this component "contains" the specified point, where the point's x and y coordinates are defined to be relative to the coordinate system of this component.public boolean contains(Point p)-
Description copied from class:
Component
Checks whether this component "contains" the specified point, where the point's x and y coordinates are defined to be relative to the coordinate system of this component.- Parameters:
p
- the point- Throws:
java.lang.NullPointerException
- ifp
isnull
- Since:
- JDK1.1
- See Also:
Component.getComponentAt(Point)
doLayout void
doLayout()Causes this container to lay out its components.public void doLayout()-
Causes this container to lay out its components. Most programs should not call this method directly, but should invoke the
validate
method instead.- Overrides:
doLayout
in classComponent
- Since:
- JDK1.1
- See Also:
LayoutManager.layoutContainer(java.awt.Container)
,setLayout(java.awt.LayoutManager)
,validate()
findComponentAt Component
findComponentAt(int x, int y)Locates the visible child component that contains the specified position.public Component findComponentAt(int x, int y)-
Locates the visible child component that contains the specified position. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.
The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container, findComponentAt will search that child to find a nested component.
- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
- null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.
- Since:
- 1.2
- See Also:
Component.contains(int, int)
,getComponentAt(int, int)
findComponentAt Component
findComponentAt(Point p)Locates the visible child component that contains the specified point.-
Locates the visible child component that contains the specified point. The top-most child component is returned in the case where there is overlap in the components. If the containing child component is a Container, this method will continue searching for the deepest nested child component. Components which are not visible are ignored during the search.
The findComponentAt method is different from getComponentAt in that getComponentAt only searches the Container's immediate children; if the containing component is a Container, findComponentAt will search that child to find a nested component.
- Parameters:
p
- the point.- Returns:
- null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned.
- Throws:
java.lang.NullPointerException
- ifp
isnull
- Since:
- 1.2
- See Also:
Component.contains(int, int)
,getComponentAt(int, int)
getAlignmentX float
getAlignmentX()Returns the alignment along the x axis.public float getAlignmentX()-
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
- Overrides:
getAlignmentX
in classComponent
getAlignmentY float
getAlignmentY()Returns the alignment along the y axis.public float getAlignmentY()-
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
- Overrides:
getAlignmentY
in classComponent
getBaseline int
getBaseline(int width, int height)Returns the baseline.public int getBaseline(int width, int height)-
Description copied from class:
Component
Returns the baseline. The baseline is measured from the top of the component. This method is primarily meant forLayoutManager
s to align components along their baseline. A return value less than 0 indicates this component does not have a reasonable baseline and thatLayoutManager
s should not align this component on its baseline.The default implementation returns -1. Subclasses that support baseline should override appropriately. If a value >= 0 is returned, then the component has a valid baseline for any size >= the minimum size and
getBaselineResizeBehavior
can be used to determine how the baseline changes with size.- Parameters:
width
- the width to get the baseline forheight
- the height to get the baseline for- Returns:
- the baseline or < 0 indicating there is no reasonable baseline
- Throws:
java.lang.IllegalArgumentException
- if width or height is < 0- Since:
- 1.6
- See Also:
Component.getBaselineResizeBehavior()
,FontMetrics
getBaselineResizeBehavior Component.BaselineResizeBehavior
getBaselineResizeBehavior()Returns an enum indicating how the baseline of the component changes as the size changes.public Component.BaselineResizeBehavior getBaselineResizeBehavior()-
Description copied from class:
Component
Returns an enum indicating how the baseline of the component changes as the size changes. This method is primarily meant for layout managers and GUI builders.The default implementation returns
BaselineResizeBehavior.OTHER
. Subclasses that have a baseline should override appropriately. Subclasses should never returnnull
; if the baseline can not be calculated returnBaselineResizeBehavior.OTHER
. Callers should first ask for the baseline usinggetBaseline
and if a value >= 0 is returned use this method. It is acceptable for this method to return a value other thanBaselineResizeBehavior.OTHER
even ifgetBaseline
returns a value less than 0.- Returns:
- an enum indicating how the baseline changes as the component size changes
- Since:
- 1.6
- See Also:
Component.getBaseline(int, int)
getBounds Rectangle
getBounds()Gets the bounds of this component in the form of aRectangle
object.public Rectangle getBounds()-
Description copied from class:
Component
Gets the bounds of this component in the form of aRectangle
object. The bounds specify this component's width, height, and location relative to its parent.- Returns:
- a rectangle indicating this component's bounds
- See Also:
Component.setBounds(int, int, int, int)
,Component.getLocation()
,Component.getSize()
getBounds Rectangle
getBounds(Rectangle rv)Stores the bounds of this component into "return value" rv and return rv.-
Description copied from class:
Component
Stores the bounds of this component into "return value" rv and return rv. If rv isnull
a newRectangle
is allocated. This version ofgetBounds
is useful if the caller wants to avoid allocating a newRectangle
object on the heap.- Parameters:
rv
- the return value, modified to the components bounds- Returns:
- rv
getComponentAt Component
getComponentAt(int x, int y)Locates the component that contains the x,y position.public Component getComponentAt(int x, int y)-
Locates the component that contains the x,y position. The top-most child component is returned in the case where there is overlap in the components. This is determined by finding the component closest to the index 0 that claims to contain the given point via Component.contains(), except that Components which have native peers take precedence over those which do not (i.e., lightweight Components).
- Overrides:
getComponentAt
in classComponent
- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
- null if the component does not contain the position. If there is no child component at the requested point and the point is within the bounds of the container the container itself is returned; otherwise the top-most child is returned.
- Since:
- JDK1.1
- See Also:
Component.contains(int, int)
getComponentAt Component
getComponentAt(Point p)Gets the component that contains the specified point.-
Gets the component that contains the specified point.
- Overrides:
getComponentAt
in classComponent
- Parameters:
p
- the point.- Returns:
- returns the component that contains the point,
or
null
if the component does not contain the point. - Since:
- JDK1.1
- See Also:
Component.contains(int, int)
getHeight int
getHeight()Returns the current height of this component.public int getHeight()-
Description copied from class:
Component
Returns the current height of this component. This method is preferable to writingcomponent.getBounds().height
, orcomponent.getSize().height
because it doesn't cause any heap allocations.- Returns:
- the current height of this component
- Since:
- 1.2
getInsets Insets
getInsets()Determines the insets of this container, which indicate the size of the container's border.public Insets getInsets()-
Determines the insets of this container, which indicate the size of the container's border.
A
Frame
object, for example, has a top inset that corresponds to the height of the frame's title bar.- Returns:
- the insets of this container.
- Since:
- JDK1.1
- See Also:
Insets
,LayoutManager
getLayout LayoutManager
getLayout()Gets the layout manager for this container.public LayoutManager getLayout()-
Gets the layout manager for this container.
- See Also:
doLayout()
,setLayout(java.awt.LayoutManager)
getLocation Point
getLocation()Gets the location of this component in the form of a point specifying the component's top-left corner.public Point getLocation()-
Description copied from class:
Component
Gets the location of this component in the form of a point specifying the component's top-left corner. The location will be relative to the parent's coordinate space.Due to the asynchronous nature of native event handling, this method can return outdated values (for instance, after several calls of
setLocation()
in rapid succession). For this reason, the recommended method of obtaining a component's position is withinjava.awt.event.ComponentListener.componentMoved()
, which is called after the operating system has finished moving the component.- Returns:
- an instance of
Point
representing the top-left corner of the component's bounds in the coordinate space of the component's parent - Since:
- JDK1.1
- See Also:
Component.setLocation(int, int)
,Component.getLocationOnScreen()
getLocation Point
getLocation(Point rv)Stores the x,y origin of this component into "return value" rv and return rv.-
Description copied from class:
Component
Stores the x,y origin of this component into "return value" rv and return rv. If rv isnull
a newPoint
is allocated. This version ofgetLocation
is useful if the caller wants to avoid allocating a newPoint
object on the heap.- Parameters:
rv
- the return value, modified to the components location- Returns:
- rv
getMaximumSize Dimension
getMaximumSize()Returns the maximum size of this container.public Dimension getMaximumSize()-
Returns the maximum size of this container. If the maximum size has not been set explicitly by
Component.setMaximumSize(Dimension)
and theLayoutManager
installed on thisContainer
is an instance ofLayoutManager2
, thenLayoutManager2.maximumLayoutSize(Container)
is used to calculate the maximum size.Note: some implementations may cache the value returned from the
LayoutManager2
. Implementations that cache need not invokemaximumLayoutSize
on theLayoutManager2
every time this method is invoked, rather theLayoutManager2
will only be queried after theContainer
becomes invalid.- Overrides:
getMaximumSize
in classComponent
- Returns:
- an instance of
Dimension
that represents the maximum size of this container. - See Also:
getPreferredSize()
,getMinimumSize()
,getLayout()
,LayoutManager2.maximumLayoutSize(Container)
,Component.getMaximumSize()
getMinimumSize Dimension
getMinimumSize()Returns the minimum size of this container.public Dimension getMinimumSize()-
Returns the minimum size of this container. If the minimum size has not been set explicitly by
Component.setMinimumSize(Dimension)
and thisContainer
has anon-null
LayoutManager
, thenLayoutManager.minimumLayoutSize(Container)
is used to calculate the minimum size.Note: some implementations may cache the value returned from the
LayoutManager
. Implementations that cache need not invokeminimumLayoutSize
on theLayoutManager
every time this method is invoked, rather theLayoutManager
will only be queried after theContainer
becomes invalid.- Overrides:
getMinimumSize
in classComponent
- Returns:
- an instance of
Dimension
that represents the minimum size of this container. - Since:
- JDK1.1
- See Also:
getPreferredSize()
,getMaximumSize()
,getLayout()
,LayoutManager.minimumLayoutSize(Container)
,Component.getMinimumSize()
getMousePosition Point
getMousePosition(boolean allowChildren)Returns the position of the mouse pointer in thisContainer
's coordinate space if theContainer
is under the mouse pointer, otherwise returnsnull
.-
Returns the position of the mouse pointer in this
Container
's coordinate space if theContainer
is under the mouse pointer, otherwise returnsnull
. This method is similar toComponent.getMousePosition()
with the exception that it can take theContainer
's children into account. IfallowChildren
isfalse
, this method will return a non-null value only if the mouse pointer is above theContainer
directly, not above the part obscured by children. IfallowChildren
istrue
, this method returns a non-null value if the mouse pointer is aboveContainer
or any of its descendants.- Parameters:
allowChildren
- true if children should be taken into account- Returns:
- mouse coordinates relative to this
Component
, or null - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true- Since:
- 1.5
- See Also:
Component.getMousePosition()
getPreferredSize Dimension
getPreferredSize()Returns the preferred size of this container.public Dimension getPreferredSize()-
Returns the preferred size of this container. If the preferred size has not been set explicitly by
Component.setPreferredSize(Dimension)
and thisContainer
has anon-null
LayoutManager
, thenLayoutManager.preferredLayoutSize(Container)
is used to calculate the preferred size.Note: some implementations may cache the value returned from the
LayoutManager
. Implementations that cache need not invokepreferredLayoutSize
on theLayoutManager
every time this method is invoked, rather theLayoutManager
will only be queried after theContainer
becomes invalid.- Overrides:
getPreferredSize
in classComponent
- Returns:
- an instance of
Dimension
that represents the preferred size of this container. - See Also:
getMinimumSize()
,getMaximumSize()
,getLayout()
,LayoutManager.preferredLayoutSize(Container)
,Component.getPreferredSize()
getSize Dimension
getSize()Returns the size of this component in the form of aDimension
object.public Dimension getSize()-
Description copied from class:
Component
Returns the size of this component in the form of aDimension
object. Theheight
field of theDimension
object contains this component's height, and thewidth
field of theDimension
object contains this component's width.- Returns:
- a
Dimension
object that indicates the size of this component - Since:
- JDK1.1
- See Also:
Component.setSize(int, int)
getSize Dimension
getSize(Dimension rv)Stores the width/height of this component into "return value" rv and return rv.-
Description copied from class:
Component
Stores the width/height of this component into "return value" rv and return rv. If rv isnull
a newDimension
object is allocated. This version ofgetSize
is useful if the caller wants to avoid allocating a newDimension
object on the heap.- Parameters:
rv
- the return value, modified to the components size- Returns:
- rv
getWidth int
getWidth()Returns the current width of this component.public int getWidth()-
Description copied from class:
Component
Returns the current width of this component. This method is preferable to writingcomponent.getBounds().width
, orcomponent.getSize().width
because it doesn't cause any heap allocations.- Returns:
- the current width of this component
- Since:
- 1.2
getX int
getX()Returns the current x coordinate of the components origin.public int getX()-
Description copied from class:
Component
Returns the current x coordinate of the components origin. This method is preferable to writingcomponent.getBounds().x
, orcomponent.getLocation().x
because it doesn't cause any heap allocations.- Returns:
- the current x coordinate of the components origin
- Since:
- 1.2
getY int
getY()Returns the current y coordinate of the components origin.public int getY()-
Description copied from class:
Component
Returns the current y coordinate of the components origin. This method is preferable to writingcomponent.getBounds().y
, orcomponent.getLocation().y
because it doesn't cause any heap allocations.- Returns:
- the current y coordinate of the components origin
- Since:
- 1.2
insets Insets
insets()Deprecated. As of JDK version 1.1, replaced bygetInsets()
.inside boolean
inside(int x, int y)Deprecated. As of JDK version 1.1, replaced by contains(int, int).@Deprecated public boolean inside(int x, int y)Deprecated. As of JDK version 1.1, replaced by contains(int, int).invalidate void
invalidate()Invalidates the container.public void invalidate()-
Invalidates the container.
If the
LayoutManager
installed on this container is an instance of theLayoutManager2
interface, then theLayoutManager2.invalidateLayout(Container)
method is invoked on it supplying thisContainer
as the argument.Afterwards this method marks this container invalid, and invalidates its ancestors. See the
Component.invalidate()
method for more details.- Overrides:
invalidate
in classComponent
- See Also:
validate()
,layout()
,LayoutManager2
isMaximumSizeSet boolean
isMaximumSizeSet()Returns true if the maximum size has been set to a non-null
value otherwise returns false.public boolean isMaximumSizeSet()-
Description copied from class:
Component
Returns true if the maximum size has been set to a non-null
value otherwise returns false.- Returns:
- true if
maximumSize
is non-null
, false otherwise - Since:
- 1.5
isMinimumSizeSet boolean
isMinimumSizeSet()Returns whether or notsetMinimumSize
has been invoked with a non-null value.public boolean isMinimumSizeSet()-
Description copied from class:
Component
Returns whether or notsetMinimumSize
has been invoked with a non-null value.- Returns:
- true if
setMinimumSize
has been invoked with a non-null value. - Since:
- 1.5
isPreferredSizeSet boolean
isPreferredSizeSet()Returns true if the preferred size has been set to a non-null
value otherwise returns false.public boolean isPreferredSizeSet()-
Description copied from class:
Component
Returns true if the preferred size has been set to a non-null
value otherwise returns false.- Returns:
- true if
setPreferredSize
has been invoked with a non-null value. - Since:
- 1.5
isValid boolean
isValid()Determines whether this component is valid.public boolean isValid()-
Description copied from class:
Component
Determines whether this component is valid. A component is valid when it is correctly sized and positioned within its parent container and all its children are also valid. In order to account for peers' size requirements, components are invalidated before they are first shown on the screen. By the time the parent container is fully realized, all its components will be valid.- Returns:
true
if the component is valid,false
otherwise- Since:
- JDK1.0
- See Also:
Component.validate()
,Component.invalidate()
isValidateRoot boolean
isValidateRoot()Indicates if this container is a validate root.public boolean isValidateRoot()-
Indicates if this container is a validate root.
Layout-related changes, such as bounds of the validate root descendants, do not affect the layout of the validate root parent. This peculiarity enables the
invalidate()
method to stop invalidating the component hierarchy when the method encounters a validate root. However, to preserve backward compatibility this new optimized behavior is enabled only when thejava.awt.smartInvalidate
system property value is set totrue
.If a component hierarchy contains validate roots and the new optimized
invalidate()
behavior is enabled, thevalidate()
method must be invoked on the validate root of a previously invalidated component to restore the validity of the hierarchy later. Otherwise, calling thevalidate()
method on the top-level container (such as aFrame
object) should be used to restore the validity of the component hierarchy.The
Window
class and theApplet
class are the validate roots in AWT. Swing introduces more validate roots.- Returns:
- whether this container is a validate root
- Since:
- 1.7
- See Also:
invalidate()
,Component.invalidate()
,JComponent.isValidateRoot()
,JComponent.revalidate()
layout void
layout()Deprecated. As of JDK version 1.1, replaced bydoLayout()
.@Deprecated public void layout()Deprecated. As of JDK version 1.1, replaced bydoLayout()
.locate Component
locate(int x, int y)Deprecated. As of JDK version 1.1, replaced bygetComponentAt(int, int)
.Deprecated. As of JDK version 1.1, replaced bygetComponentAt(int, int)
.location Point
location()Deprecated. As of JDK version 1.1, replaced bygetLocation()
.minimumSize Dimension
minimumSize()Deprecated. As of JDK version 1.1, replaced bygetMinimumSize()
.Deprecated. As of JDK version 1.1, replaced bygetMinimumSize()
.move void
move(int x, int y)Deprecated. As of JDK version 1.1, replaced bysetLocation(int, int)
.@Deprecated public void move(int x, int y)Deprecated. As of JDK version 1.1, replaced bysetLocation(int, int)
.preferredSize Dimension
preferredSize()Deprecated. As of JDK version 1.1, replaced bygetPreferredSize()
.Deprecated. As of JDK version 1.1, replaced bygetPreferredSize()
.reshape void
reshape(int x, int y, int width, int height)Deprecated. As of JDK version 1.1, replaced bysetBounds(int, int, int, int)
.@Deprecated public void reshape(int x, int y, int width, int height)Deprecated. As of JDK version 1.1, replaced bysetBounds(int, int, int, int)
.resize void
resize(Dimension d)Deprecated. As of JDK version 1.1, replaced bysetSize(Dimension)
.Deprecated. As of JDK version 1.1, replaced bysetSize(Dimension)
.resize void
resize(int width, int height)Deprecated. As of JDK version 1.1, replaced bysetSize(int, int)
.@Deprecated public void resize(int width, int height)Deprecated. As of JDK version 1.1, replaced bysetSize(int, int)
.revalidate void
revalidate()Revalidates the component hierarchy up to the nearest validate root.public void revalidate()-
Description copied from class:
Component
Revalidates the component hierarchy up to the nearest validate root.This method first invalidates the component hierarchy starting from this component up to the nearest validate root. Afterwards, the component hierarchy is validated starting from the nearest validate root.
This is a convenience method supposed to help application developers avoid looking for validate roots manually. Basically, it's equivalent to first calling the
Component.invalidate()
method on this component, and then calling theComponent.validate()
method on the nearest validate root.- Since:
- 1.7
- See Also:
isValidateRoot()
setBounds void
setBounds(int x, int y, int width, int height)Moves and resizes this component.public void setBounds(int x, int y, int width, int height)-
Description copied from class:
Component
Moves and resizes this component. The new location of the top-left corner is specified byx
andy
, and the new size is specified bywidth
andheight
.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
x
- the new x-coordinate of this componenty
- the new y-coordinate of this componentwidth
- the newwidth
of this componentheight
- the newheight
of this component- Since:
- JDK1.1
- See Also:
Component.getBounds()
,Component.setLocation(int, int)
,Component.setLocation(Point)
,Component.setSize(int, int)
,Component.setSize(Dimension)
,Component.invalidate()
setBounds void
setBounds(Rectangle r)Moves and resizes this component to conform to the new bounding rectangler
.public void setBounds(Rectangle r)-
Description copied from class:
Component
Moves and resizes this component to conform to the new bounding rectangler
. This component's new position is specified byr.x
andr.y
, and its new size is specified byr.width
andr.height
This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
r
- the new bounding rectangle for this component- Throws:
java.lang.NullPointerException
- ifr
isnull
- Since:
- JDK1.1
- See Also:
Component.getBounds()
,Component.setLocation(int, int)
,Component.setLocation(Point)
,Component.setSize(int, int)
,Component.setSize(Dimension)
,Component.invalidate()
setLayout void
setLayout(LayoutManager mgr)Sets the layout manager for this container.public void setLayout(LayoutManager mgr)-
Sets the layout manager for this container.
This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
mgr
- the specified layout manager- See Also:
doLayout()
,getLayout()
,invalidate()
setLocation void
setLocation(int x, int y)Moves this component to a new location.public void setLocation(int x, int y)-
Description copied from class:
Component
Moves this component to a new location. The top-left corner of the new location is specified by thex
andy
parameters in the coordinate space of this component's parent.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
x
- the x-coordinate of the new location's top-left corner in the parent's coordinate spacey
- the y-coordinate of the new location's top-left corner in the parent's coordinate space- Since:
- JDK1.1
- See Also:
Component.getLocation()
,Component.setBounds(int, int, int, int)
,Component.invalidate()
setLocation void
setLocation(Point p)Moves this component to a new location.public void setLocation(Point p)-
Description copied from class:
Component
Moves this component to a new location. The top-left corner of the new location is specified by pointp
. Pointp
is given in the parent's coordinate space.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
p
- the point defining the top-left corner of the new location, given in the coordinate space of this component's parent- Since:
- JDK1.1
- See Also:
Component.getLocation()
,Component.setBounds(int, int, int, int)
,Component.invalidate()
setMaximumSize void
setMaximumSize(Dimension maximumSize)Sets the maximum size of this component to a constant value.public void setMaximumSize(Dimension maximumSize)-
Description copied from class:
Component
Sets the maximum size of this component to a constant value. Subsequent calls togetMaximumSize
will always return this value. Setting the maximum size tonull
restores the default behavior.- Parameters:
maximumSize
- aDimension
containing the desired maximum allowable size- Since:
- 1.5
- See Also:
Component.getMaximumSize()
,Component.isMaximumSizeSet()
setMinimumSize void
setMinimumSize(Dimension minimumSize)Sets the minimum size of this component to a constant value.public void setMinimumSize(Dimension minimumSize)-
Description copied from class:
Component
Sets the minimum size of this component to a constant value. Subsequent calls togetMinimumSize
will always return this value. Setting the minimum size tonull
restores the default behavior.- Parameters:
minimumSize
- the new minimum size of this component- Since:
- 1.5
- See Also:
Component.getMinimumSize()
,Component.isMinimumSizeSet()
setPreferredSize void
setPreferredSize(Dimension preferredSize)Sets the preferred size of this component to a constant value.public void setPreferredSize(Dimension preferredSize)-
Description copied from class:
Component
Sets the preferred size of this component to a constant value. Subsequent calls togetPreferredSize
will always return this value. Setting the preferred size tonull
restores the default behavior.- Parameters:
preferredSize
- The new preferred size, or null- Since:
- 1.5
- See Also:
Component.getPreferredSize()
,Component.isPreferredSizeSet()
setSize void
setSize(Dimension d)Resizes this component so that it has widthd.width
and heightd.height
.public void setSize(Dimension d)-
Description copied from class:
Component
Resizes this component so that it has widthd.width
and heightd.height
.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
d
- the dimension specifying the new size of this component- Throws:
java.lang.NullPointerException
- ifd
isnull
- Since:
- JDK1.1
- See Also:
Component.setSize(int, int)
,Component.setBounds(int, int, int, int)
,Component.invalidate()
setSize void
setSize(int width, int height)Resizes this component so that it has widthwidth
and heightheight
.public void setSize(int width, int height)-
Description copied from class:
Component
Resizes this component so that it has widthwidth
and heightheight
.This method changes layout-related information, and therefore, invalidates the component hierarchy.
- Parameters:
width
- the new width of this component in pixelsheight
- the new height of this component in pixels- Since:
- JDK1.1
- See Also:
Component.getSize()
,Component.setBounds(int, int, int, int)
,Component.invalidate()
size Dimension
size()Deprecated. As of JDK version 1.1, replaced bygetSize()
.validate void
validate()Validates this container and all of its subcomponents.public void validate()-
Validates this container and all of its subcomponents.
Validating a container means laying out its subcomponents. Layout-related changes, such as setting the bounds of a component, or adding a component to the container, invalidate the container automatically. Note that the ancestors of the container may be invalidated also (see
Component.invalidate()
for details.) Therefore, to restore the validity of the hierarchy, thevalidate()
method should be invoked on the top-most invalid container of the hierarchy.Validating the container may be a quite time-consuming operation. For performance reasons a developer may postpone the validation of the hierarchy till a set of layout-related operations completes, e.g. after adding all the children to the container.
If this
Container
is not valid, this method invokes thevalidateTree
method and marks thisContainer
as valid. Otherwise, no action is performed.- Overrides:
validate
in classComponent
- See Also:
add(java.awt.Component)
,invalidate()
,isValidateRoot()
,JComponent.revalidate()
,validateTree()
validateTree protected void
validateTree()Recursively descends the container tree and recomputes the layout for any subtrees marked as needing it (those marked as invalid).protected void validateTree()-
Recursively descends the container tree and recomputes the layout for any subtrees marked as needing it (those marked as invalid). Synchronization should be provided by the method that calls this one:
validate
.- See Also:
doLayout()
,validate()
-
-
Painting Methods Modifier and Type Method and Description getIgnoreRepaint boolean
getIgnoreRepaint()public boolean getIgnoreRepaint()paint void
paint(Graphics g)Paints the container.public void paint(Graphics g)-
Paints the container. This forwards the paint to any lightweight components that are children of this container. If this method is reimplemented, super.paint(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g, paint() will not be forwarded to that child.
- Overrides:
paint
in classComponent
- Parameters:
g
- the specified Graphics window- See Also:
Component.update(Graphics)
paintAll void
paintAll(Graphics g)Paints this component and all of its subcomponents.public void paintAll(Graphics g)-
Description copied from class:
Component
Paints this component and all of its subcomponents.The origin of the graphics context, its (
0
,0
) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.- Parameters:
g
- the graphics context to use for painting- Since:
- JDK1.0
- See Also:
Component.paint(java.awt.Graphics)
paintComponents void
paintComponents(Graphics g)Paints each of the components in this container.public void paintComponents(Graphics g)-
Paints each of the components in this container.
- Parameters:
g
- the graphics context.- See Also:
Component.paint(java.awt.Graphics)
,Component.paintAll(java.awt.Graphics)
repaint void
repaint()Repaints this component.public void repaint()-
Description copied from class:
Component
Repaints this component.If this component is a lightweight component, this method causes a call to this component's
paint
method as soon as possible. Otherwise, this method causes a call to this component'supdate
method as soon as possible.Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.
- Since:
- JDK1.0
- See Also:
Component.update(Graphics)
repaint void
repaint(int x, int y, int width, int height)Repaints the specified rectangle of this component.public void repaint(int x, int y, int width, int height)-
Description copied from class:
Component
Repaints the specified rectangle of this component.If this component is a lightweight component, this method causes a call to this component's
paint
method as soon as possible. Otherwise, this method causes a call to this component'supdate
method as soon as possible.Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.
- Parameters:
x
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the height- Since:
- JDK1.0
- See Also:
Component.update(Graphics)
repaint void
repaint(long tm)Repaints the component.public void repaint(long tm)-
Description copied from class:
Component
Repaints the component. If this component is a lightweight component, this results in a call topaint
withintm
milliseconds.Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.
- Parameters:
tm
- maximum time in milliseconds before update- Since:
- JDK1.0
- See Also:
Component.paint(java.awt.Graphics)
,Component.update(Graphics)
repaint void
repaint(long tm, int x, int y, int width, int height)Repaints the specified rectangle of this component withintm
milliseconds.public void repaint(long tm, int x, int y, int width, int height)-
Description copied from class:
Component
Repaints the specified rectangle of this component withintm
milliseconds.If this component is a lightweight component, this method causes a call to this component's
paint
method. Otherwise, this method causes a call to this component'supdate
method.Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.
- Parameters:
tm
- maximum time in milliseconds before updatex
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the height- Since:
- JDK1.0
- See Also:
Component.update(Graphics)
setIgnoreRepaint void
setIgnoreRepaint(boolean ignoreRepaint)Sets whether or not paint messages received from the operating system should be ignored.public void setIgnoreRepaint(boolean ignoreRepaint)-
Description copied from class:
Component
Sets whether or not paint messages received from the operating system should be ignored. This does not affect paint events generated in software by the AWT, unless they are an immediate response to an OS-level paint message.This is useful, for example, if running under full-screen mode and better performance is desired, or if page-flipping is used as the buffer strategy.
- Since:
- 1.4
- See Also:
Component.getIgnoreRepaint()
,Canvas.createBufferStrategy(int)
,Window.createBufferStrategy(int)
,BufferStrategy
,GraphicsDevice.setFullScreenWindow(java.awt.Window)
update void
update(Graphics g)Updates the container.public void update(Graphics g)-
Updates the container. This forwards the update to any lightweight components that are children of this container. If this method is reimplemented, super.update(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g, update() will not be forwarded to that child.
- Overrides:
update
in classComponent
- Parameters:
g
- the specified Graphics window- See Also:
Component.update(Graphics)
-
-
Printing Methods Modifier and Type Method and Description list void
list()Prints a listing of this component to the standard system output streamSystem.out
.public void list()-
Description copied from class:
Component
Prints a listing of this component to the standard system output streamSystem.out
.- Since:
- JDK1.0
- See Also:
System.out
list void
list(java.io.PrintStream out)Prints a listing of this component to the specified output stream.public void list(java.io.PrintStream out)-
Description copied from class:
Component
Prints a listing of this component to the specified output stream.- Parameters:
out
- a print stream- Throws:
java.lang.NullPointerException
- ifout
isnull
- Since:
- JDK1.0
list void
list(java.io.PrintStream out, int indent)Prints a listing of this container to the specified output stream.public void list(java.io.PrintStream out, int indent)-
Prints a listing of this container to the specified output stream. The listing starts at the specified indentation.
The immediate children of the container are printed with an indentation of
indent+1
. The children of those children are printed atindent+2
and so on.- Overrides:
list
in classComponent
- Parameters:
out
- a print streamindent
- the number of spaces to indent- Throws:
java.lang.NullPointerException
- ifout
isnull
- Since:
- JDK1.0
- See Also:
Component.list(java.io.PrintStream, int)
list void
list(java.io.PrintWriter out)Prints a listing to the specified print writer.public void list(java.io.PrintWriter out)-
Description copied from class:
Component
Prints a listing to the specified print writer.- Parameters:
out
- the print writer to print to- Throws:
java.lang.NullPointerException
- ifout
isnull
- Since:
- JDK1.1
list void
list(java.io.PrintWriter out, int indent)Prints out a list, starting at the specified indentation, to the specified print writer.public void list(java.io.PrintWriter out, int indent)-
Prints out a list, starting at the specified indentation, to the specified print writer.
The immediate children of the container are printed with an indentation of
indent+1
. The children of those children are printed atindent+2
and so on.- Overrides:
list
in classComponent
- Parameters:
out
- a print writerindent
- the number of spaces to indent- Throws:
java.lang.NullPointerException
- ifout
isnull
- Since:
- JDK1.1
- See Also:
Component.list(java.io.PrintWriter, int)
print void
print(Graphics g)Prints the container.public void print(Graphics g)-
Prints the container. This forwards the print to any lightweight components that are children of this container. If this method is reimplemented, super.print(g) should be called so that lightweight components are properly rendered. If a child component is entirely clipped by the current clipping setting in g, print() will not be forwarded to that child.
- Overrides:
print
in classComponent
- Parameters:
g
- the specified Graphics window- See Also:
Component.update(Graphics)
printAll void
printAll(Graphics g)Prints this component and all of its subcomponents.public void printAll(Graphics g)-
Description copied from class:
Component
Prints this component and all of its subcomponents.The origin of the graphics context, its (
0
,0
) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.- Parameters:
g
- the graphics context to use for printing- Since:
- JDK1.0
- See Also:
Component.print(Graphics)
printComponents void
printComponents(Graphics g)Prints each of the components in this container.public void printComponents(Graphics g)-
Prints each of the components in this container.
- Parameters:
g
- the graphics context.- See Also:
Component.print(java.awt.Graphics)
,Component.printAll(java.awt.Graphics)
-
-
Other Methods Modifier and Type Method and Description add void
add(PopupMenu popup)Adds the specified popup menu to the component.public void add(PopupMenu popup)-
Description copied from class:
Component
Adds the specified popup menu to the component.- Parameters:
popup
- the popup menu to be added to the component.- Throws:
java.lang.NullPointerException
- ifpopup
isnull
- Since:
- JDK1.1
- See Also:
Component.remove(MenuComponent)
addNotify void
addNotify()Makes this Container displayable by connecting it to a native screen resource.public void addNotify()-
Makes this Container displayable by connecting it to a native screen resource. Making a container displayable will cause all of its children to be made displayable. This method is called internally by the toolkit and should not be called directly by programs.
- Overrides:
addNotify
in classComponent
- See Also:
Component.isDisplayable()
,removeNotify()
getDropTarget java.awt.dnd.DropTarget
getDropTarget()Gets theDropTarget
associated with thisComponent
.public java.awt.dnd.DropTarget getDropTarget()-
Description copied from class:
Component
Gets theDropTarget
associated with thisComponent
.
getInputContext java.awt.im.InputContext
getInputContext()Gets the input context used by this component for handling the communication with input methods when text is entered in this component.public java.awt.im.InputContext getInputContext()-
Description copied from class:
Component
Gets the input context used by this component for handling the communication with input methods when text is entered in this component. By default, the input context used for the parent component is returned. Components may override this to return a private input context.- Returns:
- the input context used by this component;
null
if no context can be determined - Since:
- 1.2
getInputMethodRequests java.awt.im.InputMethodRequests
getInputMethodRequests()Gets the input method request handler which supports requests from input methods for this component.public java.awt.im.InputMethodRequests getInputMethodRequests()-
Description copied from class:
Component
Gets the input method request handler which supports requests from input methods for this component. A component that supports on-the-spot text input must override this method to return anInputMethodRequests
instance. At the same time, it also has to handle input method events.- Returns:
- the input method request handler for this component,
null
by default - Since:
- 1.2
- See Also:
Component.addInputMethodListener(java.awt.event.InputMethodListener)
getPeer java.awt.peer.ComponentPeer
getPeer()Deprecated. As of JDK version 1.1, programs should not directly manipulate peers; replaced byboolean isDisplayable()
.@Deprecated public java.awt.peer.ComponentPeer getPeer()Deprecated. As of JDK version 1.1, programs should not directly manipulate peers; replaced byboolean isDisplayable()
.getTreeLock java.lang.Object
getTreeLock()Gets this component's locking object (the object that owns the thread synchronization monitor) for AWT component-tree and layout operations.public final java.lang.Object getTreeLock()-
Description copied from class:
Component
Gets this component's locking object (the object that owns the thread synchronization monitor) for AWT component-tree and layout operations.- Returns:
- this component's locking object
paramString protected java.lang.String
paramString()Returns a string representing the state of thisContainer
.protected java.lang.String paramString()-
Returns a string representing the state of this
Container
. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
.- Overrides:
paramString
in classComponent
- Returns:
- the parameter string of this container
remove void
remove(MenuComponent popup)Removes the specified popup menu from the component.public void remove(MenuComponent popup)-
Description copied from class:
Component
Removes the specified popup menu from the component.- Specified by:
remove
in interfaceMenuContainer
- Parameters:
popup
- the popup menu to be removed- Since:
- JDK1.1
- See Also:
Component.add(PopupMenu)
removeNotify void
removeNotify()Makes this Container undisplayable by removing its connection to its native screen resource.public void removeNotify()-
Makes this Container undisplayable by removing its connection to its native screen resource. Making a container undisplayable will cause all of its children to be made undisplayable. This method is called by the toolkit internally and should not be called directly by programs.
- Overrides:
removeNotify
in classComponent
- See Also:
Component.isDisplayable()
,addNotify()
setDropTarget void
setDropTarget(java.awt.dnd.DropTarget dt)Associate aDropTarget
with this component.public void setDropTarget(java.awt.dnd.DropTarget dt)-
Description copied from class:
Component
Associate aDropTarget
with this component. TheComponent
will receive drops only if it is enabled.- Parameters:
dt
- The DropTarget- See Also:
Component.isEnabled()
toString java.lang.String
toString()Returns a string representation of this component and its values.public java.lang.String toString()-
Description copied from class:
Component
Returns a string representation of this component and its values.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this component
- Since:
- JDK1.0
-
-
-