    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class java.awt.Component

    java.lang.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.

##

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

##

Component()
  Constructs a new component.

##

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

##

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

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

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

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

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

##

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).

##

getName

     public String getName()

  Gets the name of the component.

  Returns:
    This component's name.
  See Also:
    setName

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.
  See Also:
    getName

getParent

     public Container getParent()

  Gets the parent of this component.

  Returns:
    The parent container of this component.

getPeer

     public ComponentPeer getPeer()

  Note: getPeer() is deprecated. As of JDK version 1.1, programs should not directly manipulate peers.

getTreeLock

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

getToolkit

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

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.
  See Also:
    validate, invalidate

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.
  See Also:
    setVisible

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.
  See Also:
    setVisible

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.
  See Also:
    setEnabled

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.
  See Also:
    isEnabled

enable

     public void enable()

  Note: enable() is deprecated. As of JDK version 1.1, replaced by `setEnabled(boolean)`.

enable

     public void enable(boolean b)

  Note: enable() is deprecated. As of JDK version 1.1, replaced by `setEnabled(boolean)`.

disable

     public void disable()

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

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.
  See Also:
    isVisible

show

     public void show()

  Note: show() is deprecated. As of JDK version 1.1, replaced by `setVisible(boolean)`.

show

     public void show(boolean b)

  Note: show() is deprecated. As of JDK version 1.1, replaced by `setVisible(boolean)`.

hide

     public void hide()

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

getForeground

     public 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.
  See Also:
    java.awt.Component#setForeground

setForeground

     public void setForeground(Color c)

  Sets the foreground color of this component.

  Parameters:
    `c` - The color to become this component's foreground color.
  See Also:
    getForeground

getBackground

     public 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.
  See Also:
    setBackground

setBackground

     public void setBackground(Color c)

  Sets the background color of this component.

  Parameters:
    `c` - The color to become this component's background color.
  See Also:
    getBackground

getFont

     public 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.
  See Also:
    setFont

setFont

     public void setFont(Font f)

  Sets the font of this component.

  Parameters:
    `f` - The font to become this component's font.
  See Also:
    getFont

getLocale

     public 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.
  See Also:
    setLocale

setLocale

     public void setLocale(Locale l)

  Sets the locale of this component.

  Parameters:
    `l` - The locale to become this component's locale.
  See Also:
    getLocale

getColorModel

     public ColorModel getColorModel()

  Gets the instance of `ColorModel` used to display the component on the output device.

  Returns:
    The color model used by this component.
  See Also:
    ColorModel, getColorModel, getColorModel

getLocation

     public 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.
  See Also:
    setLocation, getLocationOnScreen

getLocationOnScreen

     public 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

location

     public Point location()

  Note: location() is deprecated. As of JDK version 1.1, replaced by `getLocation()`.

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.
  See Also:
    getLocation, setBounds

move

     public void move(int x,
                      int y)

  Note: move() is deprecated. As of JDK version 1.1, replaced by `setLocation(int, int)`.

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.
  See Also:
    getLocation, setBounds

getSize

     public 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.
  See Also:
    setSize

size

     public Dimension size()

  Note: size() is deprecated. As of JDK version 1.1, replaced by `getSize()`.

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.
  See Also:
    getSize, setBounds

resize

     public void resize(int width,
                        int height)

  Note: resize() is deprecated. As of JDK version 1.1, replaced by `setSize(int, int)`.

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.
  See Also:
    setSize, setBounds

resize

     public void resize(Dimension d)

  Note: resize() is deprecated. As of JDK version 1.1, replaced by `setSize(Dimension)`.

getBounds

     public 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

bounds

     public Rectangle bounds()

  Note: bounds() is deprecated. As of JDK version 1.1, replaced by `getBounds()`.

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, setLocation, setSize, setSize

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)`.

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.``
  See Also:
    getBounds, setLocation, setLocation, setSize, setSize

getPreferredSize

     public Dimension getPreferredSize()

  Gets the preferred size of this component.

  Returns:
    A dimension object indicating this component's preferred size.
  See Also:
    getMinimumSize, LayoutManager

preferredSize

     public Dimension preferredSize()

  Note: preferredSize() is deprecated. As of JDK version 1.1, replaced by `getPreferredSize()`.

getMinimumSize

     public Dimension getMinimumSize()

  Gets the mininimum size of this component.

  Returns:
    A dimension object indicating this component's minimum size.
  See Also:
    getPreferredSize, awtLayoutManager

minimumSize

     public Dimension minimumSize()

  Note: minimumSize() is deprecated. As of JDK version 1.1, replaced by `getMinimumSize()`.

getMaximumSize

     public Dimension getMaximumSize()

  Gets the maximum size of this component.

  Returns:
    A dimension object indicating this component's maximum size.
  See Also:
    getMinimumSize, getPreferredSize, LayoutManager

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.

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.

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

layout

     public void layout()

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

validate

     public void validate()

  Ensures that this component has a valid layout. This method is primarily intended to operate on instances of `Container`.

  See Also:
    invalidate, doLayout, LayoutManager, validate

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.

  See Also:
    validate, doLayout, LayoutManager

getGraphics

     public 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.
  See Also:
    paint

getFontMetrics

     public 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`.
  See Also:
    getFont, getPeer, getFontMetrics, getFontMetrics

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. If this parameter is null then this component will inherit the cursor of its parent.
  See Also:
    getCursor, Cursor

getCursor

     public Cursor getCursor()

  Gets the cursor set on this component.

  Returns:
    The cursor for this component.
  See Also:
    setCursor, Cursor

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.
  See Also:
    update

update

     public void update(Graphics g)

  Updates this component.

  The AWT calls the `update` method in response to a call to `repaint</code. The appearance of the component on the screen has not changed since the last call to <code>update` or `paint`. You can assume that the background is not cleared.

  The `update`method 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 (`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 specified context to use for updating.
  See Also:
    paint, repaint

paintAll

     public void paintAll(Graphics g)

  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.
  See Also:
    paint

repaint

     public void repaint()

  Repaints this component.

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

  See Also:
    update

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
  See Also:
    paint, update

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.
  See Also:
    update

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.
  See Also:
    update

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 (`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.
  See Also:
    paint

printAll

     public void printAll(Graphics g)

  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.
  See Also:
    print

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.
  See Also:
    ImageObserver, drawImage, drawImage, drawImage, drawImage, imageUpdate

createImage

     public Image createImage(ImageProducer producer)

  Creates an image from the specified image producer.

  Parameters:
    producer - the image producer
  Returns:
    the image produced.

createImage

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

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.

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.
  See Also:
    ImageObserver

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.
  See Also:
    prepareImage, checkImage, ImageObserver

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.
  See Also:
    prepareImage, checkImage, _top_

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.
  See Also:
    getComponentAt

inside

     public boolean inside(int x,
                           int y)

  Note: inside() is deprecated. As of JDK version 1.1, replaced by contains(int, int).

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.
  See Also:
    getComponentAt

getComponentAt

     public Component getComponentAt(int x,
                                     int y)

  Determines if this component or one of its immediate subcomponents contains the (x, y) location, and if so, returns the containing component. This method only looks one level deep. If the point (x, y) 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 (x, y) 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 (x, y) location; `null` if the location is outside this component.
  See Also:
    contains

locate

     public Component locate(int x,
                             int y)

  Note: locate() is deprecated. As of JDK version 1.1, replaced by getComponentAt(int, int).

getComponentAt

     public Component getComponentAt(Point p)

  Returns the component or subcomponent that contains the specified point.

  Parameters:
    p - the point.
  See Also:
    contains

deliverEvent

     public void deliverEvent(Event e)

  Note: deliverEvent() is deprecated. As of JDK version 1.1, replaced by `dispatchEvent(AWTEvent e)`.

dispatchEvent

     public final void dispatchEvent(AWTEvent e)

  Dispatches an event to this component or one of its sub components.

  Parameters:
    e - the event

postEvent

     public boolean postEvent(Event e)

  Note: postEvent() is deprecated. As of JDK version 1.1, replaced by dispatchEvent(AWTEvent).

addComponentListener

     public synchronized void addComponentListener(ComponentListener l)

  Adds the specified component listener to receive component events from this component.

  Parameters:
    l - the component listener.
  See Also:
    ComponentEvent, ComponentListener, removeComponentListener

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.
  See Also:
    ComponentEvent, ComponentListener, addComponentListener

addFocusListener

     public synchronized void addFocusListener(FocusListener l)

  Adds the specified focus listener to receive focus events from this component.

  Parameters:
    l - the focus listener.
  See Also:
    FocusEvent, FocusListener, removeFocusListener

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.
  See Also:
    FocusEvent, FocusListener, addFocusListener

addKeyListener

     public synchronized void addKeyListener(KeyListener l)

  Adds the specified key listener to receive key events from this component.

  Parameters:
    l - the key listener.
  See Also:
    KeyEvent, KeyListener, removeKeyListener

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.
  See Also:
    KeyEvent, KeyListener, addKeyListener

addMouseListener

     public synchronized void addMouseListener(MouseListener l)

  Adds the specified mouse listener to receive mouse events from this component.

  Parameters:
    l - the mouse listener.
  See Also:
    MouseEvent, MouseListener, removeMouseListener

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.
  See Also:
    MouseEvent, MouseListener, addMouseListener

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.
  See Also:
    MouseMotionEvent, MouseMotionListener, removeMouseMotionListener

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.
  See Also:
    MouseMotionEvent, MouseMotionListener, addMouseMotionListener

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.
  See Also:
    processEvent, disableEvents

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
  See Also:
    enableEvents

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.
  See Also:
    processComponentEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent

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:

  - A `ComponentListener` object is registered via `addComponentListener`.
  - Component events are enabled via `enableEvents`.

  Parameters:
    e - the component event.
  See Also:
    ComponentEvent, ComponentListener, addComponentListener, enableEvents

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:

  - A `FocusListener` object is registered via `addFocusListener`.
  - Focus events are enabled via `enableEvents`.

  Parameters:
    e - the focus event.
  See Also:
    FocusEvent, FocusListener, addFocusListener, enableEvents

processKeyEvent

     protected void processKeyEvent(KeyEvent e)

  Processes key events occurring on this component by dispatching them to any registered <codeKeyListener 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.
  See Also:
    KeyEvent, KeyListener, addKeyListener, enableEvents

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:

  - A `MouseListener` object is registered via `addMouseListener`.
  - Mouse events are enabled via `enableEvents`.

  Parameters:
    e - the mouse event.
  See Also:
    MouseEvent, MouseListener, addMouseListener, enableEvents

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:

  - A `MouseMotionListener` object is registered via `addMouseMotionListener`.
  - Mouse motion events are enabled via `enableEvents`.

  Parameters:
    e - the mouse motion event.
  See Also:
    MouseMotionEvent, MouseMotionListener, addMouseMotionListener, enableEvents

handleEvent

     public boolean handleEvent(Event evt)

  Note: handleEvent() is deprecated. As of JDK version 1.1 replaced by processEvent(AWTEvent).

mouseDown

     public boolean mouseDown(Event evt,
                              int x,
                              int y)

  Note: mouseDown() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

mouseDrag

     public boolean mouseDrag(Event evt,
                              int x,
                              int y)

  Note: mouseDrag() is deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).

mouseUp

     public boolean mouseUp(Event evt,
                            int x,
                            int y)

  Note: mouseUp() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

mouseMove

     public boolean mouseMove(Event evt,
                              int x,
                              int y)

  Note: mouseMove() is deprecated. As of JDK version 1.1, replaced by processMouseMotionEvent(MouseEvent).

mouseEnter

     public boolean mouseEnter(Event evt,
                               int x,
                               int y)

  Note: mouseEnter() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

mouseExit

     public boolean mouseExit(Event evt,
                              int x,
                              int y)

  Note: mouseExit() is deprecated. As of JDK version 1.1, replaced by processMouseEvent(MouseEvent).

keyDown

     public boolean keyDown(Event evt,
                            int key)

  Note: keyDown() is deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).

keyUp

     public boolean keyUp(Event evt,
                          int key)

  Note: keyUp() is deprecated. As of JDK version 1.1, replaced by processKeyEvent(KeyEvent).

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.

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.

  See Also:
    removeNotify

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

gotFocus

     public boolean gotFocus(Event evt,
                             Object what)

  Note: gotFocus() is deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).

lostFocus

     public boolean lostFocus(Event evt,
                              Object what)

  Note: lostFocus() is deprecated. As of JDK version 1.1, replaced by processFocusEvent(FocusEvent).

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.

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

  See Also:
    FocusEvent, addFocusListener, processFocusEvent, isFocusTraversable

transferFocus

     public void transferFocus()

  Transfers the focus to the next component.

  See Also:
    requestFocus, gotFocus

nextFocus

     public void nextFocus()

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

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.
  See Also:
    remove

remove

     public synchronized void remove(MenuComponent popup)

  Removes the specified popup menu from the component.

  Parameters:
    popup - the popup menu to be removed.
  See Also:
    add

paramString

     protected 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.

toString

     public String toString()

  Returns a string representation of this component and its values.

  Returns:
    a string representation of this component.
  Overrides:
    toString in class Object

list

     public void list()

  Prints a listing of this component to the standard system output stream `System.out`.

  See Also:
    out

list

     public void list(PrintStream out)

  Prints a listing of this component to the specified output stream.

  Parameters:
    out - a print stream.

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.
  See Also:
    println

list

     public void list(PrintWriter out)

  Prints a listing to the specified print writer.

  Parameters:
    out - The print writer to print to.

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.
  See Also:
    println

    All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.