Class java.awt.Component
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.Component

Object
   |
   +----java.awt.Component

public abstract class Component
extends Object
implements ImageObserver, MenuContainer, Serializable
A component is an object having a graphical representation that can be displayed on the screen and that can interact with the user. Examples of components are the buttons, checkboxes, and scrollbars of a typical graphical user interface.

The Component class is the abstract superclass of the nonmenu-related Abstract Window Toolkit components. Class Component can also be extended directly to create a lightweight component. A lightweight component is a component that is not associated with a native opaque window.

Version:
1.185 98/09/09
Author:
Arthur van Hoff, Sami Shaio

Variable Index

 o BOTTOM_ALIGNMENT
Ease-of-use constant for getAlignmentY.
 o CENTER_ALIGNMENT
Ease-of-use constant for getAlignmentY and getAlignmentX.
 o LEFT_ALIGNMENT
Ease-of-use constant for getAlignmentX.
 o RIGHT_ALIGNMENT
Ease-of-use constant for getAlignmentX.
 o TOP_ALIGNMENT
Ease-of-use constant for getAlignmentY().

Constructor Index

 o java.awt.Component()
Constructs a new component.

Method Index

 o action(Event, Object)
 o add(PopupMenu)
Adds the specified popup menu to the component.
 o addComponentListener(ComponentListener)
Adds the specified component listener to receive component events from this component.
 o addFocusListener(FocusListener)
Adds the specified focus listener to receive focus events from this component.
 o addKeyListener(KeyListener)
Adds the specified key listener to receive key events from this component.
 o addMouseListener(MouseListener)
Adds the specified mouse listener to receive mouse events from this component.
 o addMouseMotionListener(MouseMotionListener)
Adds the specified mouse motion listener to receive mouse motion events from this component.
 o addNotify()
Notifies this component that it has been added to a container and if a peer is required, it should be created.
 o bounds()
 o checkImage(Image, ImageObserver)
Returns the status of the construction of a screen representation of the specified image.
 o checkImage(Image, int, int, ImageObserver)
Returns the status of the construction of a screen representation of the specified image.
 o contains(int, int)
Checks whether this component "contains" the specified point, where x and y are defined to be relative to the coordinate system of this component.
 o contains(Point)
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.
 o createImage(ImageProducer)
Creates an image from the specified image producer.
 o createImage(int, int)
Creates an off-screen drawable image to be used for double buffering.
 o deliverEvent(Event)
 o disable()
 o disableEvents(long)
Disables the events defined by the specified event mask parameter from being delivered to this component.
 o dispatchEvent(AWTEvent)
Dispatches an event to this component or one of its sub components.
 o doLayout()
Prompts the layout manager to lay out this component.
 o enable()
 o enable(boolean)
 o enableEvents(long)
Enables the events defined by the specified event mask parameter to be delivered to this component.
 o getAlignmentX()
Returns the alignment along the x axis.
 o getAlignmentY()
Returns the alignment along the y axis.
 o getBackground()
Gets the background color of this component.
 o getBounds()
Gets the bounds of this component in the form of a Rectangle object.
 o getColorModel()
Gets the instance of ColorModel used to display the component on the output device.
 o getComponentAt(int, int)
Determines if this component or one of its immediate subcomponents contains the (xy) location, and if so, returns the containing component.
 o getComponentAt(Point)
Returns the component or subcomponent that contains the specified point.
 o getCursor()
Gets the cursor set on this component.
 o getFont()
Gets the font of this component.
 o getFontMetrics(Font)
Gets the font metrics for the specified font.
 o getForeground()
Gets the foreground color of this component.
 o getGraphics()
Creates a graphics context for this component.
 o getLocale()
Gets the locale of this component.
 o getLocation()
Gets the location of this component in the form of a point specifying the component's top-left corner.
 o 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.
 o getMaximumSize()
Gets the maximum size of this component.
 o getMinimumSize()
Gets the mininimum size of this component.
 o getName()
Gets the name of the component.
 o getParent()
Gets the parent of this component.
 o getPeer()
 o getPreferredSize()
Gets the preferred size of this component.
 o getSize()
Returns the size of this component in the form of a Dimension object.
 o getToolkit()
Gets the toolkit of this component.
 o getTreeLock()
Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations.
 o gotFocus(Event, Object)
 o handleEvent(Event)
 o hide()
 o imageUpdate(Image, int, int, int, int, int)
Repaints the component when the image has changed.
 o inside(int, int)
 o invalidate()
Invalidates this component.
 o isEnabled()
Determines whether this component is enabled.
 o isFocusTraversable()
Returns the value of a flag that indicates whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal.
 o isShowing()
Determines whether this component is showing on screen.
 o isValid()
Determines whether this component is valid.
 o isVisible()
Determines whether this component is visible.
 o keyDown(Event, int)
 o keyUp(Event, int)
 o layout()
 o list()
Prints a listing of this component to the standard system output stream System.out.
 o list(PrintStream)
Prints a listing of this component to the specified output stream.
 o list(PrintStream, int)
Prints out a list, starting at the specified indention, to the specified print stream.
 o list(PrintWriter)
Prints a listing to the specified print writer.
 o list(PrintWriter, int)
Prints out a list, starting at the specified indention, to the specified print writer.
 o locate(int, int)
 o location()
 o lostFocus(Event, Object)
 o minimumSize()
 o mouseDown(Event, int, int)
 o mouseDrag(Event, int, int)
 o mouseEnter(Event, int, int)
 o mouseExit(Event, int, int)
 o mouseMove(Event, int, int)
 o mouseUp(Event, int, int)
 o move(int, int)
 o nextFocus()
 o paint(Graphics)
Paints this component.
 o paintAll(Graphics)
Paints this component and all of its subcomponents.
 o paramString()
Returns the parameter string representing the state of this component.
 o postEvent(Event)
 o preferredSize()
 o prepareImage(Image, ImageObserver)
Prepares an image for rendering on this component.
 o prepareImage(Image, int, int, ImageObserver)
Prepares an image for rendering on this component at the specified width and height.
 o print(Graphics)
Prints this component.
 o printAll(Graphics)
Prints this component and all of its subcomponents.
 o processComponentEvent(ComponentEvent)
Processes component events occurring on this component by dispatching them to any registered ComponentListener objects.
 o processEvent(AWTEvent)
Processes events occurring on this component.
 o processFocusEvent(FocusEvent)
Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.
 o processKeyEvent(KeyEvent)
Processes key events occurring on this component by dispatching them to any registered objects.
 o processMouseEvent(MouseEvent)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.
 o processMouseMotionEvent(MouseEvent)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener objects.
 o remove(MenuComponent)
Removes the specified popup menu from the component.
 o removeComponentListener(ComponentListener)
Removes the specified component listener so that it no longer receives component events from this component.
 o removeFocusListener(FocusListener)
Removes the specified focus listener so that it no longer receives focus events from this component.
 o removeKeyListener(KeyListener)
Removes the specified key listener so that it no longer receives key events from this component.
 o removeMouseListener(MouseListener)
Removes the specified mouse listener so that it no longer receives mouse events from this component.
 o removeMouseMotionListener(MouseMotionListener)
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component.
 o removeNotify()
Notifies this component that it has been removed from its container and if a peers exists, it destroys it.
 o repaint()
Repaints this component.
 o repaint(long)
Repaints the component.
 o repaint(int, int, int, int)
Repaints the specified rectangle of this component.
 o repaint(long, int, int, int, int)
Repaints the specified rectangle of this component within tm milliseconds.
 o requestFocus()
Requests that this component get the input focus.
 o reshape(int, int, int, int)
 o resize(int, int)
 o resize(Dimension)
 o setBackground(Color)
Sets the background color of this component.
 o setBounds(int, int, int, int)
Moves and resizes this component.
 o setBounds(Rectangle)
Moves and resizes this component to conform to the new bounding rectangle r.
 o setCursor(Cursor)
Set the cursor image to a predefined cursor.
 o setEnabled(boolean)
Enables or disables this component, depending on the value of the parameter b.
 o setFont(Font)
Sets the font of this component.
 o setForeground(Color)
Sets the foreground color of this component.
 o setLocale(Locale)
Sets the locale of this component.
 o setLocation(int, int)
Moves this component to a new location.
 o setLocation(Point)
Moves this component to a new location.
 o setName(String)
Sets the name of the component to the specified string.
 o setSize(int, int)
Resizes this component so that it has width width and height.
 o setSize(Dimension)
Resizes this component so that it has width d.width and height d.height.
 o setVisible(boolean)
Shows or hides this component depending on the value of parameter b.
 o show()
 o show(boolean)
 o size()
 o toString()
Returns a string representation of this component and its values.
 o transferFocus()
Transfers the focus to the next component.
 o update(Graphics)
Updates this component.
 o validate()
Ensures that this component has a valid layout.

Variables

 o BOTTOM_ALIGNMENT
public static final float BOTTOM_ALIGNMENT
Ease-of-use constant for getAlignmentY. Specifies an alignment to the bottom of the component.

See Also:
getAlignmentY
 o CENTER_ALIGNMENT
public static final float CENTER_ALIGNMENT
Ease-of-use constant for getAlignmentY and getAlignmentX. Specifies an alignment to the center of the component

See Also:
getAlignmentX, getAlignmentY
 o LEFT_ALIGNMENT
public static final float LEFT_ALIGNMENT
Ease-of-use constant for getAlignmentX. Specifies an alignment to the left side of the component.

See Also:
getAlignmentX
 o RIGHT_ALIGNMENT
public static final float RIGHT_ALIGNMENT
Ease-of-use constant for getAlignmentX. Specifies an alignment to the right side of the component.

See Also:
getAlignmentX
 o TOP_ALIGNMENT
public static final float TOP_ALIGNMENT
Ease-of-use constant for getAlignmentY(). Specifies an alignment to the top of the component.

See Also:
getAlignmentY

Constructors

 o Component
protected Component()
Constructs a new component. Class Component can be extended directly to create a lightweight component that does not utilize an opaque native window. A lightweight component must be hosted by a native container somewhere higher up in the component tree (for example, by a Frame object).

Methods

 o action
public boolean action(Event evt,
                      Object what)
Note: action() is deprecated. As of JDK version 1.1, should register this component as ActionListener on component which fires action events.

 o add
public synchronized void add(PopupMenu popup)
Adds the specified popup menu to the component.

Parameters:
popup - the popup menu to be added to the component.
Since:
JDK1.1
See Also:
remove(java.awt.MenuComponent)
 o addComponentListener
public synchronized void addComponentListener(ComponentListener l)
Adds the specified component listener to receive component events from this component.

Parameters:
l - the component listener.
Since:
JDK1.1
See Also:
ComponentEvent, ComponentListener, removeComponentListener
 o addFocusListener
public synchronized void addFocusListener(FocusListener l)
Adds the specified focus listener to receive focus events from this component.

Parameters:
l - the focus listener.
Since:
JDK1.1
See Also:
FocusEvent, FocusListener, removeFocusListener
 o addKeyListener
public synchronized void addKeyListener(KeyListener l)
Adds the specified key listener to receive key events from this component.

Parameters:
l - the key listener.
Since:
JDK1.1
See Also:
KeyEvent, KeyListener, removeKeyListener
 o addMouseListener
public synchronized void addMouseListener(MouseListener l)
Adds the specified mouse listener to receive mouse events from this component.

Parameters:
l - the mouse listener.
Since:
JDK1.1
See Also:
MouseEvent, MouseListener, removeMouseListener
 o addMouseMotionListener
public synchronized void addMouseMotionListener(MouseMotionListener l)
Adds the specified mouse motion listener to receive mouse motion events from this component.

Parameters:
l - the mouse motion listener.
Since:
JDK1.1
See Also:
MouseMotionEvent, MouseMotionListener, removeMouseMotionListener
 o addNotify
public void addNotify()
Notifies this component that it has been added to a container and if a peer is required, it should be created. This method should be called by Container.add, and not by user code directly.

Since:
JDK1.0
See Also:
removeNotify
 o bounds
public java.awt.Rectangle bounds()
Note: bounds() is deprecated. As of JDK version 1.1, replaced by getBounds().

 o checkImage
public int checkImage(Image image,
                      ImageObserver observer)
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 - the Image object whose status is being checked.
observer - the ImageObserver 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:
prepareImage(java.awt.Image, int, int, java.awt.image.ImageObserver), checkImage(java.awt.Image, int, int, java.awt.image.ImageObserver), ImageObserver
 o checkImage
public int checkImage(Image image,
                      int width,
                      int height,
                      ImageObserver observer)
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 of Component calls its peer's checkImage method to calculate the flags. If this component does not yet have a peer, the component's toolkit's checkImage method is called instead.

Information on the flags returned by this method can be found with the discussion of the ImageObserver interface.

Parameters:
image - the Image object whose status is being checked.
width - the width of the scaled version whose status is to be checked.
height - the height of the scaled version whose status is to be checked.
observer - the ImageObserver 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:
prepareImage(java.awt.Image, int, int, java.awt.image.ImageObserver), checkImage(java.awt.Image, int, int, java.awt.image.ImageObserver), _top_
 o contains
public boolean contains(int x,
                        int y)
Checks whether this component "contains" the specified point, where x and y are defined to be relative to the coordinate system of this component.

Parameters:
x - the x coordinate of the point.
y - the y coordinate of the point.
Since:
JDK1.1
See Also:
getComponentAt(int, int)
 o contains
public 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.

Parameters:
p - the point.
Since:
JDK1.1
See Also:
getComponentAt(java.awt.Point)
 o createImage
public java.awt.Image createImage(ImageProducer producer)
Creates an image from the specified image producer.

Parameters:
producer - the image producer
Returns:
the image produced.
Since:
JDK1.0
 o createImage
public java.awt.Image createImage(int width,
                                  int height)
Creates an 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.
Since:
JDK1.0
 o deliverEvent
public void deliverEvent(Event e)
Note: deliverEvent() is deprecated. As of JDK version 1.1, replaced by dispatchEvent(AWTEvent e).

 o disable
public void disable()
Note: disable() is deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).

 o disableEvents
protected final void disableEvents(long eventsToDisable)
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:
enableEvents
 o dispatchEvent
public final void dispatchEvent(AWTEvent e)
Dispatches an event to this component or one of its sub components.

Parameters:
e - the event
 o doLayout
public void doLayout()
Prompts the layout manager to lay out this component. This is usually called when the component (more specifically, container) is validated.

See Also:
validate, LayoutManager
 o enable
public void enable()
Note: enable() is deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).

 o enable
public void enable(boolean b)
Note: enable() is deprecated. As of JDK version 1.1, replaced by setEnabled(boolean).

 o enableEvents
protected final void enableEvents(long eventsToEnable)
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 to processEvent regardless of whether or not a listener is registered.

Parameters:
eventsToEnable - the event mask defining the event types.
Since:
JDK1.1
See Also:
processEvent, disableEvents
 o getAlignmentX
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.

 o getAlignmentY
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.

 o getBackground
public java.awt.Color getBackground()
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:
setBackground(java.awt.Color)
 o getBounds
public java.awt.Rectangle getBounds()
Gets the bounds of this component in the form of a Rectangle 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:
setBounds, getLocation, getSize
 o getColorModel
public java.awt.image.ColorModel getColorModel()
Gets the instance of ColorModel used to display the component on the output device.

Returns:
The color model used by this component.
Since:
JDK1.0
See Also:
ColorModel, getColorModel(), getColorModel()
 o getComponentAt
public java.awt.Component getComponentAt(int x,
                                         int y)
Determines if this component or one of its immediate subcomponents contains the (xy) location, and if so, returns the containing component. This method only looks one level deep. If the point (xy) is inside a subcomponent that itself has subcomponents, it does not go looking down the subcomponent tree.

The locate method of Component simply returns the component itself if the (xy) coordinate location is inside its bounding box, and null otherwise.

Parameters:
x - the x coordinate.
y - the y coordinate.
Returns:
the component or subcomponent that contains the (xy) location; null if the location is outside this component.
Since:
JDK1.0
See Also:
contains(int, int)
 o getComponentAt
public java.awt.Component getComponentAt(Point p)
Returns the component or subcomponent that contains the specified point.

Parameters:
p - the point.
Since:
JDK1.1
See Also:
contains
 o getCursor
public java.awt.Cursor getCursor()
Gets the cursor set on this component.

Returns:
The cursor for this component.
Since:
JDK1.1
See Also:
setCursor, Cursor
 o getFont
public java.awt.Font getFont()
Gets the font of this component.

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:
setFont
 o getFontMetrics
public java.awt.FontMetrics getFontMetrics(Font font)
Gets the font metrics for the specified font.

Parameters:
font - The font for which font metrics is to be obtained.
font - the font.
Returns:
The font metrics for font.
Since:
JDK1.0
See Also:
getFont, getPeer(), getFontMetrics(java.awt.Font), getFontMetrics(java.awt.Font)
 o getForeground
public java.awt.Color getForeground()
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:
java.awt.Component#setForeground(java.awt.Color)
 o getGraphics
public java.awt.Graphics getGraphics()
Creates a graphics context for this component. This method will return null if this component is currently not on the screen.

Returns:
A graphics context for this component, or null if it has none.
Since:
JDK1.0
See Also:
paint
 o getLocale
public java.util.Locale getLocale()
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 the Component 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:
setLocale
 o getLocation
public java.awt.Point getLocation()
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.

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:
setLocation, getLocationOnScreen
 o getLocationOnScreen
public java.awt.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.

Returns:
An instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen.
See Also:
setLocation, getLocation
 o getMaximumSize
public java.awt.Dimension getMaximumSize()
Gets the maximum size of this component.

Returns:
A dimension object indicating this component's maximum size.
See Also:
getMinimumSize, getPreferredSize, LayoutManager
 o getMinimumSize
public java.awt.Dimension getMinimumSize()
Gets the mininimum size of this component.

Returns:
A dimension object indicating this component's minimum size.
See Also:
getPreferredSize, awtLayoutManager
 o getName
public java.lang.String getName()
Gets the name of the component.

Returns:
This component's name.
Since:
JDK1.1
See Also:
setName
 o getParent
public java.awt.Container getParent()
Gets the parent of this component.

Returns:
The parent container of this component.
Since:
JDK1.0
 o getPeer
public java.awt.peer.ComponentPeer getPeer()
Note: getPeer() is deprecated. As of JDK version 1.1, programs should not directly manipulate peers.

 o getPreferredSize
public java.awt.Dimension getPreferredSize()
Gets the preferred size of this component.

Returns:
A dimension object indicating this component's preferred size.
See Also:
getMinimumSize, LayoutManager
 o getSize
public java.awt.Dimension getSize()
Returns the size of this component in the form of a Dimension object. The height field of the Dimension object contains this component's height, and the width field of the Dimension object contains this component's width.

Returns:
A Dimension object that indicates the size of this component.
Since:
JDK1.1
See Also:
setSize
 o getToolkit
public java.awt.Toolkit getToolkit()
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
 o getTreeLock
public final java.lang.Object getTreeLock()
Gets this component's locking object (the object that owns the thread sychronization monitor) for AWT component-tree and layout operations.

Returns:
This component's locking object.
 o gotFocus
public boolean gotFocus(Event evt,
                        Object what)
Note: gotFocus() is deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).

 o handleEvent
public boolean handleEvent(Event evt)
Note: handleEvent() is deprecated. As of JDK version 1.1 replaced by processEvent(AWTEvent).

 o hide
public void hide()
Note: hide() is deprecated. As of JDK version 1.1, replaced by setVisible(boolean).

 o imageUpdate
public boolean imageUpdate(Image img,
                           int flags,
                           int x,
                           int y,
                           int w,
                           int h)
Repaints the component when the image has changed. This imageUpdate method of an ImageObserver is called when more information about an image which had been previously requested using an asynchronous routine such as the drawImage method of Graphics becomes available. See the definition of imageUpdate for more information on this method and its arguments.

The imageUpdate method of Component 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 value true, 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, and height arguments depends on the value of the infoflags argument.

Parameters:
img - the image being observed.
infoflags - see imageUpdate for more information.
x - the x coordinate.
y - the y coordinate.
width - the width.
height - the height.
Returns:
true if the flags indicate that the image is completely loaded; false otherwise.
Since:
JDK1.0
See Also:
ImageObserver, drawImage(java.awt.Image, int, int, java.awt.Color, java.awt.image.ImageObserver), drawImage(java.awt.Image, int, int, java.awt.image.ImageObserver), drawImage(java.awt.Image, int, int, int, int, java.awt.Color, java.awt.image.ImageObserver), drawImage(java.awt.Image, int, int, int, int, java.awt.image.ImageObserver), imageUpdate(java.awt.Image, int, int, int, int, int)
 o inside
public boolean inside(int x,
                      int y)
Note: inside() is deprecated. As of JDK version 1.1, replaced by contains(int, int).

 o invalidate
public void invalidate()
Invalidates this component. This component and all parents above it are marked as needing to be laid out. This method can be called often, so it needs to execute quickly.

Since:
JDK1.0
See Also:
validate, doLayout, LayoutManager
 o isEnabled
public boolean isEnabled()
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 its setEnabled method.

Returns:
true if the component is enabled; false otherwise.
Since:
JDK1.0
See Also:
setEnabled
 o isFocusTraversable
public boolean isFocusTraversable()
Returns the value of a flag that indicates whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal. If this method returns "false", this component may still request the keyboard focus using requestFocus(), but it will not automatically be assigned focus during tab traversal.

Returns:
true if this component is focus-traverable; false otherwise.
Since:
JDK1.1
 o isShowing
public boolean isShowing()
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.

Returns:
true if the component is showing; false otherwise.
Since:
JDK1.0
See Also:
setVisible
 o isValid
public boolean isValid()
Determines whether this component is valid. Components are invalidated when they are first shown on the screen.

Returns:
true if the component is valid; false otherwise.
Since:
JDK1.0
See Also:
validate, invalidate
 o isVisible
public boolean isVisible()
Determines whether this component is visible. Components are initially visible, with the exception of top level components such as Frame objects.

Returns:
true if the component is visible; false otherwise.
Since:
JDK1.0
See Also:
setVisible
 o keyDown
public boolean keyDown(Event evt,
                       int key)
Note: keyDown() is deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).

 o keyUp
public boolean keyUp(Event evt,
                     int key)
Note: keyUp() is deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).

 o layout
public void layout()
Note: layout() is deprecated. As of JDK version 1.1, replaced by doLayout().

 o list
public void list()
Prints a listing of this component to the standard system output stream System.out.

Since:
JDK1.0
See Also:
out
 o list
public void list(PrintStream out)
Prints a listing of this component to the specified output stream.

Parameters:
out - a print stream.
Since:
JDK1.0
 o list
public void list(PrintStream out,
                 int indent)
Prints out a list, starting at the specified indention, to the specified print stream.

Parameters:
out - a print stream.
indent - number of spaces to indent.
Since:
JDK1.0
See Also:
println(java.lang.Object)
 o list
public void list(PrintWriter out)
Prints a listing to the specified print writer.

Parameters:
out - The print writer to print to.
Since:
JDK1.1
 o list
public void list(PrintWriter out,
                 int indent)
Prints out a list, starting at the specified indention, to the specified print writer.

Parameters:
out - The print writer to print to.
indent - The number of spaces to indent.
Since:
JDK1.1
See Also:
println(java.lang.Object)
 o locate
public java.awt.Component locate(int x,
                                 int y)
Note: locate() is deprecated. As of JDK version 1.1, replaced by getComponentAt(int, int).

 o location
public java.awt.Point location()
Note: location() is deprecated. As of JDK version 1.1, replaced by getLocation().

 o lostFocus
public boolean lostFocus(Event evt,
                         Object what)
Note: lostFocus() is deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).

 o minimumSize
public java.awt.Dimension minimumSize()
Note: minimumSize() is deprecated. As of JDK version 1.1, replaced by getMinimumSize().

 o mouseDown
public boolean mouseDown(Event evt,
                         int x,
                         int y)
Note: mouseDown() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

 o mouseDrag
public boolean mouseDrag(Event evt,
                         int x,
                         int y)
Note: mouseDrag() is deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).

 o mouseEnter
public boolean mouseEnter(Event evt,
                          int x,
                          int y)
Note: mouseEnter() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

 o mouseExit
public boolean mouseExit(Event evt,
                         int x,
                         int y)
Note: mouseExit() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

 o mouseMove
public boolean mouseMove(Event evt,
                         int x,
                         int y)
Note: mouseMove() is deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).

 o mouseUp
public boolean mouseUp(Event evt,
                       int x,
                       int y)
Note: mouseUp() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

 o move
public void move(int x,
                 int y)
Note: move() is deprecated. As of JDK version 1.1, replaced by setLocation(int, int).

 o nextFocus
public void nextFocus()
Note: nextFocus() is deprecated. As of JDK version 1.1, replaced by transferFocus().

 o paint
public void paint(Graphics g)
Paints this component. This method is called when the contents of the component should be painted in response to the component first being shown or damage needing repair. The clip rectangle in the Graphics parameter will be set to the area which needs to be painted.

Parameters:
g - The graphics context to use for painting.
Since:
JDK1.0
See Also:
update
 o paintAll
public void paintAll(Graphics g)
Paints this component and all of its subcomponents.

The origin of the graphics context, its (00) 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:
paint
 o paramString
protected java.lang.String paramString()
Returns the parameter string representing the state of this component. This string is useful for debugging.

Returns:
the parameter string of this component.
Since:
JDK1.0
 o postEvent
public boolean postEvent(Event e)
Note: postEvent() is deprecated. As of JDK version 1.1, replaced by dispatchEvent(AWTEvent).

 o preferredSize
public java.awt.Dimension preferredSize()
Note: preferredSize() is deprecated. As of JDK version 1.1, replaced by getPreferredSize().

 o prepareImage
public boolean prepareImage(Image image,
                            ImageObserver observer)
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 - the Image for which to prepare a screen representation.
observer - the ImageObserver 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
 o prepareImage
public boolean prepareImage(Image image,
                            int width,
                            int height,
                            ImageObserver observer)
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 of Image for which to prepare a screen representation.
width - the width of the desired screen representation.
height - the height of the desired screen representation.
observer - the ImageObserver 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
 o print
public void print(Graphics g)
Prints this component. Applications should override this method for components that must do special processing before being printed or should be printed differently than they are painted.

The default implementation of this method calls the paint method.

The origin of the graphics context, its (00) 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:
paint(java.awt.Graphics)
 o printAll
public void printAll(Graphics g)
Prints this component and all of its subcomponents.

The origin of the graphics context, its (00) 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:
print(java.awt.Graphics)
 o processComponentEvent
protected void processComponentEvent(ComponentEvent e)
Processes component events occurring on this component by dispatching them to any registered ComponentListener objects.

This method is not called unless component events are enabled for this component. Component events are enabled when one of the following occurs:

Parameters:
e - the component event.
Since:
JDK1.1
See Also:
ComponentEvent, ComponentListener, addComponentListener, enableEvents
 o processEvent
protected void processEvent(AWTEvent e)
Processes events occurring on this component. By default this method calls the appropriate process<event type>Event method for the given class of event.

Parameters:
e - the event.
Since:
JDK1.1
See Also:
processComponentEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent
 o processFocusEvent
protected void processFocusEvent(FocusEvent e)
Processes focus events occurring on this component by dispatching them to any registered FocusListener objects.

This method is not called unless focus events are enabled for this component. Focus events are enabled when one of the following occurs:

Parameters:
e - the focus event.
Since:
JDK1.1
See Also:
FocusEvent, FocusListener, addFocusListener, enableEvents
 o processKeyEvent
protected void processKeyEvent(KeyEvent e)
Processes key events occurring on this component by dispatching them to any registered 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 via addKeyListener.
  • Key events are enabled via enableEvents.

Parameters:
e - the key event.
Since:
JDK1.1
See Also:
KeyEvent, KeyListener, addKeyListener, enableEvents
 o processMouseEvent
protected void processMouseEvent(MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects.

This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:

Parameters:
e - the mouse event.
Since:
JDK1.1
See Also:
MouseEvent, MouseListener, addMouseListener, enableEvents
 o processMouseMotionEvent
protected void processMouseMotionEvent(MouseEvent e)
Processes mouse motion events occurring on this component by dispatching them to any registered MouseMotionListener 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:

Parameters:
e - the mouse motion event.
Since:
JDK1.1
See Also:
MouseMotionEvent, MouseMotionListener, addMouseMotionListener, enableEvents
 o remove
public synchronized void remove(MenuComponent popup)
Removes the specified popup menu from the component.

Parameters:
popup - the popup menu to be removed.
Since:
JDK1.1
See Also:
add(java.awt.PopupMenu)
 o removeComponentListener
public synchronized void removeComponentListener(ComponentListener l)
Removes the specified component listener so that it no longer receives component events from this component.

Parameters:
l - the component listener.
Since:
JDK1.1
See Also:
ComponentEvent, ComponentListener, addComponentListener
 o removeFocusListener
public synchronized void removeFocusListener(FocusListener l)
Removes the specified focus listener so that it no longer receives focus events from this component.

Parameters:
l - the focus listener.
Since:
JDK1.1
See Also:
FocusEvent, FocusListener, addFocusListener
 o removeKeyListener
public synchronized void removeKeyListener(KeyListener l)
Removes the specified key listener so that it no longer receives key events from this component.

Parameters:
l - the key listener.
Since:
JDK1.1
See Also:
KeyEvent, KeyListener, addKeyListener
 o removeMouseListener
public synchronized void removeMouseListener(MouseListener l)
Removes the specified mouse listener so that it no longer receives mouse events from this component.

Parameters:
l - the mouse listener.
Since:
JDK1.1
See Also:
MouseEvent, MouseListener, addMouseListener
 o removeMouseMotionListener
public synchronized void removeMouseMotionListener(MouseMotionListener l)
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component.

Parameters:
l - the mouse motion listener.
Since:
JDK1.1
See Also:
MouseMotionEvent, MouseMotionListener, addMouseMotionListener
 o removeNotify
public void removeNotify()
Notifies this component that it has been removed from its container and if a peers exists, it destroys it. This method should be called by Container.remove, and not by user code directly.

See Also:
addNotify
 o repaint
public void repaint()
Repaints this component.

This method causes a call to this component's update method as soon as possible.

Since:
JDK1.0
See Also:
update(java.awt.Graphics)
 o repaint
public void repaint(long tm)
Repaints the component. This will result in a call to update within tm milliseconds.

Parameters:
tm - maximum time in milliseconds before update
Since:
JDK1.0
See Also:
paint, update(java.awt.Graphics)
 o repaint
public void repaint(int x,
                    int y,
                    int width,
                    int height)
Repaints the specified rectangle of this component.

This method causes a call to this component's update method as soon as possible.

Parameters:
x - the x coordinate.
y - the y coordinate.
width - the width.
height - the height.
Since:
JDK1.0
See Also:
update(java.awt.Graphics)
 o repaint
public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Repaints the specified rectangle of this component within tm milliseconds.

This method causes a call to this component's update method.

Parameters:
tm - maximum time in milliseconds before update.
x - the x coordinate.
y - the y coordinate.
width - the width.
height - the height.
Since:
JDK1.0
See Also:
update(java.awt.Graphics)
 o requestFocus
public void requestFocus()
Requests that this component get the input focus.

This component's gotFocus method is called when this method is successful. The component must be visible on the screen for this request to be granted

Since:
JDK1.0
See Also:
FocusEvent, addFocusListener, processFocusEvent, isFocusTraversable
 o reshape
public void reshape(int x,
                    int y,
                    int width,
                    int height)
Note: reshape() is deprecated. As of JDK version 1.1, replaced by setBounds(int, int, int, int).

 o resize
public void resize(int width,
                   int height)
Note: resize() is deprecated. As of JDK version 1.1, replaced by setSize(int, int).

 o resize
public void resize(Dimension d)
Note: resize() is deprecated. As of JDK version 1.1, replaced by setSize(Dimension).

 o setBackground
public void setBackground(Color c)
Sets the background color of this component.

Parameters:
c - The color to become this component's background color.
Since:
JDK1.0
See Also:
getBackground
 o setBounds
public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height.

Parameters:
x - The new x-coordinate of this component.
y - The new y-coordinate of this component.
width - The new width of this component.
height - The new height of this component.
See Also:
getBounds, setLocation(int, int), setLocation(java.awt.Point), setSize(int, int), setSize(java.awt.Dimension)
 o setBounds
public void setBounds(Rectangle r)
Moves and resizes this component to conform to the new bounding rectangle r. This component's new position is specified by r.x and r.y, and its new size is specified by r.width and r.height

Parameters:
r - The new bounding rectangle for this component.
Since:
JDK1.1
See Also:
getBounds, setLocation(int, int), setLocation(java.awt.Point), setSize(int, int), setSize(java.awt.Dimension)
 o setCursor
public synchronized void setCursor(Cursor cursor)
Set the cursor image to a predefined cursor.

Parameters:
cursor - One of the constants defined by the Cursor class.
Since:
JDK1.1
See Also:
getCursor, Cursor
 o setEnabled
public void setEnabled(boolean b)
Enables or disables this component, depending on the value of the parameter b. An enabled component can respond to user input and generate events. Components are enabled initially by default.

Parameters:
b - If true, this component is enabled; otherwise this component is disabled.
Since:
JDK1.1
See Also:
isEnabled
 o setFont
public void setFont(Font f)
Sets the font of this component.

Parameters:
f - The font to become this component's font.
Since:
JDK1.0
See Also:
getFont
 o setForeground
public void setForeground(Color c)
Sets the foreground color of this component.

Parameters:
c - The color to become this component's foreground color.
Since:
JDK1.0
See Also:
getForeground
 o setLocale
public void setLocale(Locale l)
Sets the locale of this component.

Parameters:
l - The locale to become this component's locale.
Since:
JDK1.1
See Also:
getLocale
 o setLocation
public void setLocation(int x,
                        int y)
Moves this component to a new location. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent.

Parameters:
x - The x-coordinate of the new location's top-left corner in the parent's coordinate space.
y - The y-coordinate of the new location's top-left corner in the parent's coordinate space.
Since:
JDK1.1
See Also:
getLocation, setBounds
 o setLocation
public void setLocation(Point p)
Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space.

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:
getLocation, setBounds
 o setName
public void setName(String name)
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:
getName
 o setSize
public void setSize(int width,
                    int height)
Resizes this component so that it has width width and height.

Parameters:
width - The new width of this component in pixels.
height - The new height of this component in pixels.
Since:
JDK1.1
See Also:
getSize, setBounds
 o setSize
public void setSize(Dimension d)
Resizes this component so that it has width d.width and height d.height.

Parameters:
d - The dimension specifying the new size of this component.
Since:
JDK1.1
See Also:
setSize, setBounds
 o setVisible
public void setVisible(boolean b)
Shows or hides this component depending on the value of parameter b.

Parameters:
b - If true, shows this component; otherwise, hides this component.
Since:
JDK1.1
See Also:
isVisible
 o show
public void show()
Note: show() is deprecated. As of JDK version 1.1, replaced by setVisible(boolean).

 o show
public void show(boolean b)
Note: show() is deprecated. As of JDK version 1.1, replaced by setVisible(boolean).

 o size
public java.awt.Dimension size()
Note: size() is deprecated. As of JDK version 1.1, replaced by getSize().

 o toString
public java.lang.String toString()
Returns a string representation of this component and its values.

Returns:
a string representation of this component.
Overrides:
toString in class Object
Since:
JDK1.0
 o transferFocus
public void transferFocus()
Transfers the focus to the next component.

Since:
JDK1.1s
See Also:
requestFocus, gotFocus
 o update
public void update(Graphics g)
Updates this component.

The AWT calls the update method in response to a call to repaintupdate or paint. You can assume that the background is not cleared.

The updatemethod of Component does the following:

  • Clears this component by filling it with the background color.
  • Sets the color of the graphics context to be the foreground color of this component.
  • Calls this component's paint method to completely redraw this component.

The origin of the graphics context, its (00) 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 specified context to use for updating.
Since:
JDK1.0
See Also:
paint, repaint()
 o validate
public void validate()
Ensures that this component has a valid layout. This method is primarily intended to operate on instances of Container.

Since:
JDK1.0
See Also:
invalidate, doLayout(), LayoutManager, validate

All Packages  Class Hierarchy  This Package  Previous  Next  Index