Packages This Package Prev Next Index
§1.10 Class Component
public abstract class java.awt.Component
extends java.lang.Object (I-§1.12)
implements java.awt.image.ImageObserver (II-§2.11)
{
// Methods
public boolean action(Event evt, Object what); §1.10.1
public void addNotify(); §1.10.2
public Rectangle bounds(); §1.10.3
public int checkImage(Image image, §1.10.4
ImageObserver observer);
public int checkImage(Image image, §1.10.5
int width, int height,
ImageObserver observer);
public Image createImage(ImageProducer producer); §1.10.6
public Image createImage(int width, int height); §1.10.7
public void deliverEvent(Event evt); §1.10.8
public void disable(); §1.10.9
public void enable(); §1.10.10
public void enable(boolean cond); §1.10.11
public Color getBackground(); §1.10.12
public ColorModel getColorModel(); §1.10.13
public Font getFont(); §1.10.14
public FontMetrics getFontMetrics(Font font); §1.10.15
public Color getForeground(); §1.10.16
public Graphics getGraphics(); §1.10.17
public Container getParent(); §1.10.18
public ComponentPeer getPeer(); §1.10.19
public Toolkit getToolkit(); §1.10.20
public boolean gotFocus(Event evt, Object what); §1.10.21
public boolean handleEvent(Event evt); §1.10.22
public void hide(); §1.10.23
public boolean imageUpdate(Image img, int flags, int x, §1.10.24
int y, int w, int h);
public boolean inside(int x, int y); §1.10.25
public void invalidate(); §1.10.26
public boolean isEnabled(); §1.10.27
public boolean isShowing(); §1.10.28
public boolean isValid(); §1.10.29
public boolean isVisible(); §1.10.30
public boolean keyDown(Event evt, int key); §1.10.31
public boolean keyUp(Event evt, int key); §1.10.32
public void layout(); §1.10.33
public void list(); §1.10.34
public void list(PrintStream out); §1.10.35
public void list(PrintStream out, int indent); §1.10.36
public Component locate(int x, int y); §1.10.37
public Point location(); §1.10.38
public boolean lostFocus(Event evt, Object what); §1.10.39
public Dimension minimumSize(); §1.10.40
public boolean mouseDown(Event evt, int x, int y); §1.10.41
public boolean mouseDrag(Event evt, int x, int y); §1.10.42
public boolean mouseEnter(Event evt, int x, int y); §1.10.43
public boolean mouseExit(Event evt, int x, int y); §1.10.44
public boolean mouseMove(Event evt, int x, int y); §1.10.45
public boolean mouseUp(Event evt, int x, int y); §1.10.46
public void move(int x, int y); §1.10.47
public void nextFocus(); §1.10.48
public void paint(Graphics g); §1.10.49
public void paintAll(Graphics g); §1.10.50
protected String paramString(); §1.10.51
public boolean postEvent(Event evt); §1.10.52
public Dimension preferredSize(); §1.10.53
public boolean §1.10.54
prepareImage(Image image, ImageObserver observer);
public §1.10.55
prepareImage(Image image, int width, int height,
ImageObserver observer);
public void print(Graphics g); §1.10.56
public void printAll(Graphics g); §1.10.57
public void removeNotify(); §1.10.58
public void repaint(); §1.10.59
public void repaint(int x, int y, int width, int height); §1.10.60
public void repaint(long tm); §1.10.61
public void repaint(long tm, int x, int y, §1.10.62
int width, int height);
public void requestFocus(); §1.10.63
public void reshape(int x, int y, int width, int height); §1.10.64
public void resize(Dimension d); §1.10.65
public void resize(int width, int height); §1.10.66
public void setBackground(Color c); §1.10.67
public void setFont(Font f); §1.10.68
public void setForeground(Color c); §1.10.69
public void show(); §1.10.70
public void show(boolean cond); §1.10.71
public Dimension size(); §1.10.72
public String toString(); §1.10.73
public void update(Graphics g); §1.10.74
public void validate(); §1.10.75
}
The Component class is the abstract superclass of many of the Abstract Window Toolkit
classes. It represents something that has a position, a size, can be painted on the screen,
and can receive input events.
action
public boolean action(Event evt, Object what)
- This method is called when an action occurs inside this component. This
method is usually called by handleEvent (II-§1.10.22), in which case the
what argument contains the arg field of the event argument. The specific
value and type of the what argument depends on the component that originally triggered the action.
- The method returns true to indicate that it has successfully handled the
action or false if the event that triggered the action should be passed up to
the component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The action method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
what
-
the action
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
-
addNotify
public void addNotify()
- This method notifies the Component to create a peer. This peer allows the
application to change the look of a component without changing its functionality.
- The addNotify method of Component sets a flag indicating that the component needs to be laid out again because its size has possibly changed.
- Most applications do not call this method directly.
- See Also:
- getPeer (II-§1.10.19)
removeNotify (II-§1.10.58).
bounds
public Rectangle bounds()
- Returns:
- the containing rectangle of this component.
- See Also:
- reshape (II-§1.10.64).
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 (II-§1.10.55) method to force the loading of an
image.
- The checkImage method of Component calls its peer's checkImage
method (II-§3.6.1) to calculate the flags. If this component does not yet
have a peer, the component's toolkit's checkImage method (II-§1.41.2) is
called instead.
- Information on the flags returned by this method can be found in II-§2.11.
- Parameters:
image
-
the Image 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 (II-§2.11) flags indicating
what information about the image is currently available.
checkImage
public int checkImage(Image image, int width, int height,
ImageObserver observer)
- Returns the status of the construction of a scaled screen representation of
the specified image.
- This method does not cause the image to begin loading. An application
must use the prepareImage (II-§1.10.55) method to force the loading of an
image.
- The checkImage method of Component calls its peer's checkImage
method (II-§3.6.1) to calculate the flags. If this component does not yet
have a peer, the component's toolkit's checkImage method (II-§1.41.2) is
called instead.
- Information on the flags returned by this method can be found in II-§2.11.
- Parameters:
image
-
the Image whose status is being checked
width
-
the width of the scaled version to check the status of
height
-
the height of the scaled version to check the status of
observer
-
the ImageObserver object to be notified as the image is being
prepared
- Returns:
- the bitwise inclusive OR of the ImageObserver flags for the data that is
currently available.
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)
- Parameters:
width
-
the specified width
height
-
the specified height
- Returns:
- an off-screen drawable image, which can be used for double buffering.
deliverEvent
public void deliverEvent(Event evt)
- Delivers an event to this component or one of its subcomponents.
- The deliverEvent method of Component calls the component's postEvent
method (II-§1.10.52) on the event.
- Parameters:
evt
-
the event
- See Also:
- handleEvent (II-§1.10.22).
disable
public void disable()
- Makes this component insensitive to user input.
- See Also:
- isEnabled (II-§1.10.27)
enable (II-§1.10.10).
enable
public void enable()
- Makes this component sensitive to user input. This is the default.
- See Also:
- isEnabled (II-§1.10.27)
disable (II-§1.10.9).
enable
public void enable(boolean cond)
- If the boolean argument is true, enables this component. If false, disables it.
- Parameters:
cond
-
a boolean indicating whether to enable or disable this component
getBackground
public Color getBackground()
- Determines the background color of this component. If this component
has not specified a background color using the setBackground method
(II-§1.10.67), the background color of its parent component is returned.
- Returns:
- the background color of this component.
getColorModel
public ColorModel getColorModel()
- Detetermins the color model of this component. The ColorModel (II-§2.1) is
an abstract class that encapsulates how to translate between pixel values of
an image and its red, green, blue, and alpha (transparency) components.
- The getColorModel method of Component calls its peer's getColorModel
method (II-§3.6.7) to determine the component's color model. If this component does not yet have a peer, the component's toolkit's getColorModel
method (II-§1.41.22) is called instead.
- Returns:
- the color model of this component.
getFont
public Font getFont()
- Determines the font of this component. If this component has not yet specified a font using the setFont method (II-§1.10.68), the font of its parent
component is returned.
- Returns:
- the font of this component.
getFontMetrics
public FontMetrics getFontMetrics(Font font)
- Determines the font metrics for the specified font when rendered by a platform-dependent toolkit.
- The getFontMetrics method checks to see if this component has a peer
(II-§1.10.19). If so, the peer's getFontMetrics method (II-§3.6.8) is called.
Otherwise, the component's toolkit's get-Font-Metrics method (II-§1.41.25) is
called.
- Parameters:
font
-
the font
- Returns:
- the font metrics for the specified font.
- See Also:
- getFont (II-§1.10.14).
getForeground
public Color getForeground()
- Determines the foreground color of this component. If this component has
not specified a background color using the setForeground method
(II-§1.10.69), the background color of its parent component is returned.
- Returns:
- the foreground color of this component.
getGraphics
public Graphics getGraphics()
- Returns:
- the graphics context of this component; this method returns null if the
component does not currently have a peer.
- See Also:
- paint (II-§1.10.49).
getParent
public Container getParent()
- Returns:
- the parent of this component.
getPeer
public ComponentPeer getPeer()
- Returns:
- the peer of this component.
getToolkit
public Toolkit getToolkit()
- The toolkit is used to create this component's peer when its its add-Notify
method (II-§1.10.2) is called.
- A Component's toolkit is determined by its containing Frame (II-§1.19).
- Returns:
- the toolkit of this component.
gotFocus
public boolean gotFocus(Event evt, Object what)
- This method is called when the this component receives the input focus.
This method is usually called by handleEvent (II-§1.10.22), in which case
the what argument contains the arg field of the event argument.
- The method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
the component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The getFocus method of Component simply returns false.
- The what argument is currently always null.
- Parameters:
evt
-
the event that caused the action
what
-
the action
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
- See Also:
- requestFocus (II-§1.10.63)
lostFocus (II-§1.10.39).
handleEvent
public boolean handleEvent(Event evt)
- This method is called when any event occurs inside this component.
- The method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
the component's parent.
- The handleEvent method of Component determines the type of event, and
calls one of the following methods, if appropriate:
action (II-§1.10.1)
gotFocus (II-§1.10.21) lostFocus (II-§1.10.39)
keyDown (II-§1.10.31) keyUp (II-§1.10.32)
mouseEnter (II-§1.10.43) mouseExit (II-§1.10.44)
mouseMove (II-§1.10.45) mouseDrag (II-§1.10.42)
mouseDown (II-§1.10.41) mouseUp (II-§1.10.46)
and returns whatever value that method returns. If none of those methods
is appropriate, then handleEvent returns false.
- All the above methods are called with the event as their first argument. The
action method is called with the arg field of the event as its second argument. The keyUp and keyDown are passed the key field of the event as its
second argument. The six mouse methods are passed the x and y fields of
the event as their second and third argument, respectively.1
- Parameters:
nevt
-
the event
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
hide
public void hide()
- Hides this component. The component continues to exist and be in its containing object, but it is not visible and does not have any space allocated
for it.
- See Also:
- isVisible (II-§1.10.30)
show (II-§1.10.70).
imageUpdate
public boolean
imageUpdate(Image img, int flags, int x, int y,
int w, int h)
- This imageUpdate method of an ImageObserver (such as Component) is called
when more information about an image which had been previously
requested using an asynchronous interface (such as draw-Image) becomes
available. See §2.11.9 on page 311 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
infoflags argument.
- Parameters:
img
-
the image being observed
infoflags
-
see §2.11.9 for more information
x
-
an x coordinate
y
-
a y coordinate
width
-
the width
height
-
the height
- Returns:
- true if the flags have indicated that the image is completely loaded;
false otherwise.
inside
public boolean inside(int x, int y)
- Determines if the specified location is inside this component.
- The inside method of Component returns true if the location is inside
the bounding box (II-§1.10.3) of the component.
- Parameters:
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the specified location lies within this component; false
otherwise.
- See Also:
- locate (II-§1.10.37).
invalidate
public void invalidate()
- Invalidates this component. This component is marked as having changed.
The next call to the validate (II-§1.10.75) method on this component or its
parent(s) causes the component to be laid out again.
- See Also:
- layout (II-§1.10.33)
- LayoutManager (II-§1.43).
isEnabled
public boolean isEnabled()
- Indicates whether this component is enabled to receive events. By default,
components are initially enabled.
- A component is disabled by calling its disable method (II-§1.10.9). A component is enabled by calling its enable method (II-§1.10.10)
- Returns:
- true if this component is enabled; false otherwise.
isShowing
public boolean isShowing()
- Indicates whether this component is visible. A component is showing if it
is visible (II-§1.10.30) and is inside a container this is both visible and
showing.
- A component is hidden by calling its hide method (II-§1.10.23). A component is made visible by calling its show method (II-§1.10.70).
- Returns:
- true if this component is showing; false otherwise.
isValid
public boolean isValid()
- Indicates whether this component is valid. A component is valid if it has a
peer and it and its subcomponents have been properly laid out.
- Returns:
- true if this component is valid; false otherwise.
- See Also:
- validate (II-§1.10.75)
invalidate (II-§1.10.26).
isVisible
public boolean isVisible()
- Indicates whether this component is visible. Except for top-level components such as a frame, components are visible unless they have been specifically been made invisible by a call to the hide method (II-§1.10.23).
- Returns:
- true if this component is showing; false otherwise.
- See Also:
- show (II-§1.10.70).
keyDown
public boolean keyDown(Event evt, int key)
- This method is called when a key is pressed and this component has the
focus. This method is usually called by handleEvent (II-§1.10.22), in which
case the key argument contains the key field of the event argument.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
the component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The keyDown method of Component simply returns false.
- Note that the key argument is an int rather than a char.
- Parameters:
evt
-
the event that caused the action
key
-
the key that has been pressed
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
keyUp
public boolean keyUp(Event evt, int key)
- This method is called when a key is released and this component has the
focus. This method is usually called by handleEvent (II-§1.10.22), in which
case the key argument contains the key field of the event argument.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The keyUp method of Component simply returns false.
- Note that the key argument is an int rather than a char.
- Parameters:
evt
-
the event that caused the action
key
-
the key that has been pressed
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
layout
public void layout()
- This method is called to lay out the subcomponents of this component so
that they fit inside the borders of this component.
- This method is called when this component is validated by a call to the validate method (II-§1.10.75). Most applications should not call this method
directly.
- The layout method of Component does nothing.
- See Also:
- LayoutManager (II-§1.43).
list
public void list()
- Prints a listing of this component to System.out (I-§1.18.3).
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 a listing of this component to the specified output stream. The listing starts at the specified indentation.
- The list method of Component calls the println method (I-§2.18.23) on the
component after indenting by the specified amount.
- Parameters:
out
-
a print stream
indent
-
number of spaces to indent
locate
public Component locate(int x, int y)
- Determines if this component or one of its subcomponents contains the
coordinate, and if so returns the containing component. This
method only looks one level deep. If the point 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
coordinate is inside (II-§1.10.25) its bounding box, and null otherwise.
- Parameters:
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- the component or subcomponent that contains the coordinate ;
null if the coordinate is outside this component.
location
public Point location()
- Returns:
- the location of this component in its parent's coordinate space.
- See Also:
- move (II-§1.10.47).
lostFocus
public boolean lostFocus(Event evt, Object what)
- This method is called when this component loses the input focus. This
method is usually called by handleEvent (II-§1.10.22), in which case the
what argument contains the arg field of the event argument.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The getFocus method of Component simply returns false.
- The what argument is currently always null.
- Parameters:
evt
-
the event that caused the action
what
-
the action that's occuring
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
- See Also:
- requestFocus (II-§1.10.63)
gotFocus (II-§1.10.21).
minimumSize
public Dimension minimumSize()
- Determines the minimum size of thiscomponent.
- The minimumSize method of Component checks to see if the component has a
peer (II-§1.10.19). If so, the minimumSize request is passed to the peer
(II-§3.6.13). Otherwise, the minimum size is the width and height specified by the most recent reshape (II-§1.10.64) or resize (II-§1.10.65) method
call.
- Returns:
- the minimum size of this component.
- See Also:
- preferredSize (II-§1.10.53)
LayoutManager (II-§1.43).
mouseDown
public boolean mouseDown(Event evt, int x, int y)
- This method is called when the mouse button is pushed inside this component. This method is usually called by handleEvent (II-§1.10.22), in which
case the x and y arguments contains the x and y field of the event argument.The coordinate is relative to the top-left corner of this component.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The mouseDown method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
mouseDrag
public boolean mouseDrag(Event evt, int x, int y)
- This method is called when the mouse button is moved inside this component with the button pushed. This method is usually called by handleEvent
(II-§1.10.22), in which case the x and y arguments contains the x and y
field of the event argument.The coordinate is relative to the top-
left corner of this component.
- Mouse drag events continue to get sent to this component even when the
mouse has left the bounds of the component. The drag events continue
until a mouse up event occurs.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The mouseDrag method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
mouseEnter
public boolean mouseEnter(Event evt, int x, int y)
- This method is called when the mouse first enters this component. This
method is usually called by handleEvent (II-§1.10.22), in which case the x
and y arguments contains the x and y field of the event argument. The
coordinate is relative to the top-left corner of this component.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The mouseEnter method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
mouseExit
public boolean mouseExit(Event evt, int x, int y)
- This method is called when the mouse exits this component. This method
is usually called by handleEvent (II-§1.10.22), in which case the x and y
arguments contains the x and y field of the event argument. The
coordinate is relative to the top-left corner of this component. Most applications should return either true or the value of super.handleEvent(evt).
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The mouseEixt method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
mouseMove
public boolean mouseMove(Event evt, int x, int y)
- This method is called when the mouse is moved inside this component
with the mouse button not pushed. This method is usually called by handleEvent (II-§1.10.22), in which case the x and y arguments contains the x
and y field of the event argument. The coordinate is relative to the
top-left corner of this component.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The mouseMove method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
mouseUp
public boolean mouseUp(Event evt, int x, int y)
- This method is called when the mouse button is released inside this component. This method is usually called by handleEvent (II-§1.10.22), in
which case the x and y arguments contains the x and y field of the event
argument. The coordinate is relative to the top-left corner of the
component.
- This method returns true to indicate that it has successfully handled the
action; or false if the event that triggered the action should be passed up to
this component's parent. Most applications should return either true or the
value of super.handleEvent(evt).
- The mouseUp method of Component simply returns false.
- Parameters:
evt
-
the event that caused the action
x
-
the x coordinate
y
-
the y coordinate
- Returns:
- true if the event has been handled and no further action is necessary;
false if the event is to be given to the component's parent.
move
public void move(int x, int y)
- Moves this component to the coordinate in the parent's coordinate
space. The coordinate is relative to the top-left corner of the parent component.
- Components that are in a container with a layout manager should not call
this method explicitly.
- Parameters:
x
-
the x coordinate
y
-
the y coordinate
- See Also:
- location (II-§1.10.38)
reshape (II-§1.10.64).
nextFocus
public void nextFocus()
- Moves the input focus to the next component, as determined by the component's peer (II-§3.6.14).
- See Also:
- requestFocus (II-§1.10.63)
gotFocus (II-§1.10.21).
paint
public void paint(Graphics g)
- Paints this component. Most application components, including applets,
override this method.
- The paint method of Component calls the repaint method (II-§3.6.19) of this
component's peer.
- The coordinate of the graphics context is the top-left corner of this
components. The clipping region of the graphics context is the bounding
rectangle of this component.
- The paint method of Component calls the repaint method (II-§3.6.19) of this
component's peer.
- Parameters:
g
-
the graphics context to use for painting
- See Also:
- update (II-§1.10.74).
paintAll
public void paintAll(Graphics g)
- Paints this component and all of its subcomponents.
- The coordinate of the graphics context 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 (II-§1.10.49).
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.
postEvent
public boolean postEvent(Event evt)
- Posts an event to this component by calling its handleEvent method
(II-§1.10.22). If handleEvent returns false, the event is posted to this component's parent.
- If this component and all of its parents return false, the event is passed to
this component's peer object's handleEvent method (II-§3.6.11).
- Parameters:
evt
-
the event
- Returns:
- true if this component, one of its parents, or this component's peer
handled the event; false otherwise.
- See Also:
- deliverEvent (II-§1.10.8).
preferredSize
public Dimension this()
- Determines the preferred size of the component.
- The preferredSize method of Component checks to see if this component has a
peer (II-§1.10.19). If so, the preferredSize request is passed to the peer
(II-§3.6.16). Otherwise, the preferred size is the width and height specified
by the most recent reshape (II-§1.10.64) or resize (II-§1.10.65) method call.
- Returns:
- the preferred size of this component.
- See Also:
- minimumSize (II-§1.10.40)
LayoutManager (II-§1.43).
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 to prepare a screen representation for
observer
-
the ImageObserver (II-§2.11) 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 Image to prepare a screen representation for
width
-
the width of the desired screen representation
height
-
the height of the desired screen representation
observer
-
the ImageObserver (II-§2.11) object to be notified as the image
is being prepared
- Returns:
- true if the image has already been fully prepared; false otherwise.
print
public void print(Graphics g)
- Prints this component. Applications should override this method for components that must do special processing before being printed.
- The print method of Component calls the paint method (II-§1.10.49).
- The coordinate of the graphics context 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 (II-§1.10.49).
printAll
public void printAll(Graphics g)
- Paints this component and all of its subcomponents.
- The coordinate of the graphics context 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 (II-§1.10.56).
removeNotify
public void removeNotify()
- Notifies this component and all its subcomponents to destroy their peers.
Applications should not call this method directly. It is called when a component is removed (§1.11.19 §1.11.20) from its container.
- The removeNotify method of Component removes the components peer and
has the peer clean up after itself by calling its dispose method (II-§3.6.5).
- See Also:
- getPeer (II-§1.10.19)
addNotify (II-§1.10.2).
repaint
public void repaint()
- Repaints this component.
- This method causes a call to this component's update method (II-§1.10.74)
as soon as possible.
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 (II-§1.10.74)
as soon as possible.
- Parameters:
x
-
the x coordinate
y
-
the y coordinate
width
-
the width
height
-
the height
repaint
public void repaint(long tm)
- Repaints theis component within tm milliseconds.
- This method causes a call to this component's update method (II-§1.10.74).
- Parameters:
tm
-
maximum time in milliseconds before 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 (II-§1.10.74).
- Parameters:
tm
-
maximum time in milliseconds before update
x
-
the x coordinate
y
-
the y coordinate
width
-
the width
height
-
the height
requestFocus
public void requestFocus()
- Requests that this component get the input focus
- This component's gotFocus method (II-§1.10.21) is called when this
method is successful.
- The requestFocus method of Component calls the request-Focus method
(II-§3.6.21) of the component's peer.
reshape
public void reshape(int x, int y, int width, int height)
- Reshapes this component to the specified bounding box in its parent's
coordinate space. Components that are in a container with a layout manager should not call this method explicitly.
- Parameters:
x
-
the x coordinate
y
-
the y coordinate
width
-
the width of this component
height
-
the height of this component
- See Also:
- bounds (II-§1.10.3)
move (II-§1.10.47)
resize (II-§1.10.66).
resize
public void resize(Dimension d)
- Resizes this component to the width and height specified by the dimension
argument. Components that are in a container with a layout manager
should not call this method explicitly.
- Parameters:
d
-
the new dimension for this component
- See Also:
- size (II-§1.10.72)
reshape (II-§1.10.64).
resize
public void resize(int width, int height)
- Resizes this component to the specified width and height. Components
that are in a container with a layout manager should not call this method
explicitly.
- Parameters:
width
-
the new width of this component
height
-
the new height of this component
- See Also:
- size (II-§1.10.72)
reshape (II-§1.10.64).
setBackground
public void setBackground(Color c)
- Sets the background color of this component.
- The setBackground method of Component calls the setBackground method
(II-§3.6.23) of the component's peer.
- Parameters:
c
-
the color
- See Also:
- getBackground (II-§1.10.12).
setFont
public void setFont(Font f)
- Sets the font of this component.
- The setFont method of Component calls the setFont method (II-§3.6.24) of the
component's peer.
- Parameters:
f
-
the font
- See Also:
- getFont (II-§1.10.14).
setForeground
public void setForeground(Color c)
- Sets the foreground color of this component.
- The setForeground method of Component calls the setForeground method
(II-§3.6.25) of the component's peer.
- Parameters:
c
-
the color
- See Also:
- getForeground (II-§1.10.16).
show
public void show()
- Shows this component; if this component had been made invisible by a
call to the hide method (II-§1.10.23), makes this component visible again.
- See Also:
- isVisible (II-§1.10.30).
show
public void show(boolean cond)
- If the boolean argument is true, makes this component visible. If false, makes
this component invisible.
- Parameters:
cond
-
if true, show this component; if false, hide this component.
- See Also:
- show (II-§1.10.70)
hide (II-§1.10.23).
size
public Dimension size()
- Returns:
- the current size of this component.
- See Also:
- resize (II-§1.10.65).
toString
public String toString()
- Returns:
- a string representation of this component.
- Overrides:
- toString in class Object (I-§1.12.9).
update
public void update(Graphics g)
- Updates this component.
- The AWT calls the update method in response to a call to repaint
(II-§1.10.59). The appearance of the component on the screen has not
changed since the last call to update or paint.
- The update method of Component:
- 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 (II-§1.10.49) to completely redraw
this component.
- The coordinate of the graphics context is the top-left corner of this
components. The clipping region of the graphics context is the bounding
rectangle of this component
- Parameters:
g
-
the graphics context to use for updating
validate
public void validate()
- Validates this component if necessary. This component and any subcomponents are laid out (II-§1.10.33) again, if necessary.
- See Also:
- invalidate (II-§1.10.26)
LayoutManager (II-§1.43).
1
In Java 1.0, AWT does not send all components mouse, keyboard, and focus
events. Each component documents the events that AWT sends it.
Packages This Package Prev Next Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to doug.kramer@sun.com