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
-
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()
.
-
java.awt.Component()
- Constructs a new component.
-
action(Event, Object)
-
-
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()
-
-
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)
-
-
disable()
-
-
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()
-
-
enable(boolean)
-
-
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()
-
-
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)
-
-
handleEvent(Event)
-
-
hide()
-
-
imageUpdate(Image, int, int, int, int, int)
- Repaints the component when the image has changed.
-
inside(int, int)
-
-
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)
-
-
keyUp(Event, int)
-
-
layout()
-
-
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)
-
-
location()
-
-
lostFocus(Event, Object)
-
-
minimumSize()
-
-
mouseDown(Event, int, int)
-
-
mouseDrag(Event, int, int)
-
-
mouseEnter(Event, int, int)
-
-
mouseExit(Event, int, int)
-
-
mouseMove(Event, int, int)
-
-
mouseUp(Event, int, int)
-
-
move(int, int)
-
-
nextFocus()
-
-
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)
-
-
preferredSize()
-
-
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
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(long)
-
Repaints the component.
-
repaint(int, int, int, int)
-
Repaints the specified rectangle of this 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)
-
-
resize(int, int)
-
-
resize(Dimension)
-
-
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(int, int)
- Resizes this component so that it has width
width
and height
.
-
setSize(Dimension)
-
Resizes this component so that it has width
d.width
and height d.height
.
-
setVisible(boolean)
- Shows or hides this component depending on the value of parameter
b
.
-
show()
-
-
show(boolean)
-
-
size()
-
-
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.
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
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
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
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
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).
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.
-
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)
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
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
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
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
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
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
bounds
public java.awt.Rectangle bounds()
- Note: bounds() is deprecated.
As of JDK version 1.1,
replaced by
getBounds()
.
-
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
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_
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)
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)
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
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
deliverEvent
public void deliverEvent(Event e)
- Note: deliverEvent() is deprecated.
As of JDK version 1.1,
replaced by
dispatchEvent(AWTEvent e)
.
-
disable
public void disable()
- Note: disable() is deprecated.
As of JDK version 1.1,
replaced by
setEnabled(boolean)
.
-
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
dispatchEvent
public final void dispatchEvent(AWTEvent e)
- Dispatches an event to this component or one of its sub components.
- Parameters:
- e - the event
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
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)
.
-
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
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.
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)
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
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()
getComponentAt
public java.awt.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.
- Since:
- JDK1.0
- See Also:
- contains(int, int)
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
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
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
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)
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)
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
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
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
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
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
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
getName
public java.lang.String getName()
- Gets the name of the component.
- Returns:
- This component's name.
- Since:
- JDK1.1
- See Also:
- setName
getParent
public java.awt.Container getParent()
- Gets the parent of this component.
- Returns:
- The parent container of this component.
- Since:
- JDK1.0
getPeer
public java.awt.peer.ComponentPeer getPeer()
- Note: getPeer() is deprecated.
As of JDK version 1.1,
programs should not directly manipulate peers.
-
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
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
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
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.
gotFocus
public boolean gotFocus(Event evt,
Object what)
- Note: gotFocus() is deprecated.
As of JDK version 1.1,
replaced by processFocusEvent(FocusEvent).
-
handleEvent
public boolean handleEvent(Event evt)
- Note: handleEvent() is deprecated.
As of JDK version 1.1
replaced by processEvent(AWTEvent).
-
hide
public void hide()
- Note: hide() is deprecated.
As of JDK version 1.1,
replaced by
setVisible(boolean)
.
-
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)
inside
public boolean inside(int x,
int y)
- Note: inside() is deprecated.
As of JDK version 1.1,
replaced by contains(int, int).
-
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
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
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
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
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
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
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).
-
layout
public void layout()
- Note: layout() is deprecated.
As of JDK version 1.1,
replaced by
doLayout()
.
-
list
public void list()
- Prints a listing of this component to the standard system output
stream
System.out
.
- Since:
- JDK1.0
- 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.
- Since:
- JDK1.0
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)
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
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)
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).
-
location
public java.awt.Point location()
- Note: location() is deprecated.
As of JDK version 1.1,
replaced by
getLocation()
.
-
lostFocus
public boolean lostFocus(Event evt,
Object what)
- Note: lostFocus() is deprecated.
As of JDK version 1.1,
replaced by processFocusEvent(FocusEvent).
-
minimumSize
public java.awt.Dimension minimumSize()
- Note: minimumSize() is deprecated.
As of JDK version 1.1,
replaced by
getMinimumSize()
.
-
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).
-
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).
-
mouseMove
public boolean mouseMove(Event evt,
int x,
int y)
- Note: mouseMove() 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).
-
move
public void move(int x,
int y)
- Note: move() is deprecated.
As of JDK version 1.1,
replaced by
setLocation(int, int)
.
-
nextFocus
public void nextFocus()
- Note: nextFocus() is deprecated.
As of JDK version 1.1,
replaced by transferFocus().
-
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
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.
- Since:
- JDK1.0
- See Also:
- paint
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
postEvent
public boolean postEvent(Event e)
- Note: postEvent() is deprecated.
As of JDK version 1.1,
replaced by dispatchEvent(AWTEvent).
-
preferredSize
public java.awt.Dimension preferredSize()
- Note: preferredSize() is deprecated.
As of JDK version 1.1,
replaced by
getPreferredSize()
.
-
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
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
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.
- Since:
- JDK1.0
- See Also:
- paint(java.awt.Graphics)
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.
- Since:
- JDK1.0
- See Also:
- print(java.awt.Graphics)
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.
- Since:
- JDK1.1
- See Also:
- ComponentEvent, ComponentListener, addComponentListener, 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.
- Since:
- JDK1.1
- See Also:
- processComponentEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent
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.
- Since:
- JDK1.1
- 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
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
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.
- Since:
- JDK1.1
- 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.
- Since:
- JDK1.1
- See Also:
- MouseMotionEvent, MouseMotionListener, addMouseMotionListener, enableEvents
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)
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
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
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
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
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
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
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)
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)
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)
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)
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
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)
.
-
resize
public void resize(int width,
int height)
- Note: resize() is deprecated.
As of JDK version 1.1,
replaced by
setSize(int, int)
.
-
resize
public void resize(Dimension d)
- Note: resize() is deprecated.
As of JDK version 1.1,
replaced by
setSize(Dimension)
.
-
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
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)
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)
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
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
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
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
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
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
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
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
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
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
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
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)
.
-
size
public java.awt.Dimension size()
- Note: size() is deprecated.
As of JDK version 1.1,
replaced by
getSize()
.
-
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
transferFocus
public void transferFocus()
- Transfers the focus to the next component.
- Since:
- JDK1.1s
- See Also:
- requestFocus, gotFocus
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 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.
- Since:
- JDK1.0
- See Also:
- paint, repaint()
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