Modifier and Type |
Method and Description |
|
bounds |
Deprecated. As of JDK version 1.1,
replaced by getBounds() .
Deprecated. As of JDK version 1.1,
replaced by getBounds() .
|
|
contains |
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.
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 pointy - the y coordinate of the point- Since:
- JDK1.1
- See Also:
getComponentAt(int, int)
|
|
contains |
boolean contains(Point p)
Checks whether this component "contains" the specified point,
where the point's x and y coordinates are defined
to be relative to the coordinate system of this component.
public boolean contains( Point p)
-
Checks whether this component "contains" the specified point,
where the point's x and y coordinates are defined
to be relative to the coordinate system of this component.
- Parameters:
p - the point
- Throws:
java.lang.NullPointerException - if p is null - Since:
- JDK1.1
- See Also:
getComponentAt(Point)
|
|
doLayout |
void doLayout()
Prompts the layout manager to lay out this component.
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
|
|
getAlignmentX |
float getAlignmentX()
Returns the alignment along the x axis.
public float getAlignmentX()
-
Returns the alignment along the x axis. This specifies how
the component would like to be aligned relative to other
components. The value should be a number between 0 and 1
where 0 represents alignment along the origin, 1 is aligned
the furthest away from the origin, 0.5 is centered, etc.
|
|
getAlignmentY |
float getAlignmentY()
Returns the alignment along the y axis.
public float getAlignmentY()
-
Returns the alignment along the y axis. This specifies how
the component would like to be aligned relative to other
components. The value should be a number between 0 and 1
where 0 represents alignment along the origin, 1 is aligned
the furthest away from the origin, 0.5 is centered, etc.
|
|
getBaseline |
int getBaseline(int width,
int height)
Returns the baseline.
public int getBaseline(int width,
int height)
-
Returns the baseline. The baseline is measured from the top of
the component. This method is primarily meant for
LayoutManager s to align components along their
baseline. A return value less than 0 indicates this component
does not have a reasonable baseline and that
LayoutManager s should not align this component on
its baseline.
The default implementation returns -1. Subclasses that support
baseline should override appropriately. If a value >= 0 is
returned, then the component has a valid baseline for any
size >= the minimum size and getBaselineResizeBehavior
can be used to determine how the baseline changes with size.
- Parameters:
width - the width to get the baseline forheight - the height to get the baseline for
- Returns:
- the baseline or < 0 indicating there is no reasonable
baseline
- Throws:
java.lang.IllegalArgumentException - if width or height is < 0- Since:
- 1.6
- See Also:
getBaselineResizeBehavior() ,
FontMetrics
|
|
getBaselineResizeBehavior |
Returns an enum indicating how the baseline of the component
changes as the size changes.
-
Returns an enum indicating how the baseline of the component
changes as the size changes. This method is primarily meant for
layout managers and GUI builders.
The default implementation returns
BaselineResizeBehavior.OTHER . Subclasses that have a
baseline should override appropriately. Subclasses should
never return null ; if the baseline can not be
calculated return BaselineResizeBehavior.OTHER . Callers
should first ask for the baseline using
getBaseline and if a value >= 0 is returned use
this method. It is acceptable for this method to return a
value other than BaselineResizeBehavior.OTHER even if
getBaseline returns a value less than 0.
- Returns:
- an enum indicating how the baseline changes as the component
size changes
- Since:
- 1.6
- See Also:
getBaseline(int, int)
|
|
getBounds |
Gets the bounds of this component in the form of a
Rectangle object.
-
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(int, int, int, int) ,
getLocation() ,
getSize()
|
|
getBounds |
Stores the bounds of this component into "return value" rv and
return rv.
-
Stores the bounds of this component into "return value" rv and
return rv. If rv is null a new
Rectangle is allocated.
This version of getBounds is useful if the caller
wants to avoid allocating a new Rectangle object
on the heap.
- Parameters:
rv - the return value, modified to the components bounds
- Returns:
- rv
|
|
getComponentAt |
Determines if this component or one of its immediate
subcomponents contains the (x, y) location,
and if so, returns the containing component.
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 coordinatey - 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 |
Returns the component or subcomponent that contains the
specified point.
-
Returns the component or subcomponent that contains the
specified point.
- Parameters:
p - the point- Since:
- JDK1.1
- See Also:
contains(int, int)
|
|
getHeight |
int getHeight()
Returns the current height of this component.
public int getHeight()
-
Returns the current height of this component.
This method is preferable to writing
component.getBounds().height ,
or component.getSize().height because it
doesn't cause any heap allocations.
- Returns:
- the current height of this component
- Since:
- 1.2
|
|
getLocation |
Gets the location of this component in the form of a
point specifying the component's top-left corner.
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.
Due to the asynchronous nature of native event handling, this
method can return outdated values (for instance, after several calls
of setLocation() in rapid succession). For this
reason, the recommended method of obtaining a component's position is
within java.awt.event.ComponentListener.componentMoved() ,
which is called after the operating system has finished moving the
component.
- Returns:
- an instance of
Point representing
the top-left corner of the component's bounds in
the coordinate space of the component's parent - Since:
- JDK1.1
- See Also:
setLocation(int, int) ,
getLocationOnScreen()
|
|
getLocation |
Point getLocation(Point rv)
Stores the x,y origin of this component into "return value" rv
and return rv.
-
Stores the x,y origin of this component into "return value" rv
and return rv. If rv is null a new
Point is allocated.
This version of getLocation is useful if the
caller wants to avoid allocating a new Point
object on the heap.
- Parameters:
rv - the return value, modified to the components location
- Returns:
- rv
|
|
getMaximumSize |
Gets the maximum size of this component.
|
|
getMinimumSize |
Gets the mininimum size of this component.
|
|
getPreferredSize |
Gets the preferred size of this component.
-
Gets the preferred size of this component.
- Returns:
- a dimension object indicating this component's preferred size
- See Also:
getMinimumSize() ,
LayoutManager
|
|
getSize |
Returns the size of this component in the form of a
Dimension object.
-
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(int, int)
|
|
getSize |
Stores the width/height of this component into "return value" rv
and return rv.
-
Stores the width/height of this component into "return value" rv
and return rv. If rv is null a new
Dimension object is allocated. This version of
getSize is useful if the caller wants to avoid
allocating a new Dimension object on the heap.
- Parameters:
rv - the return value, modified to the components size
- Returns:
- rv
|
|
getWidth |
int getWidth()
Returns the current width of this component.
public int getWidth()
-
Returns the current width of this component.
This method is preferable to writing
component.getBounds().width ,
or component.getSize().width because it
doesn't cause any heap allocations.
- Returns:
- the current width of this component
- Since:
- 1.2
|
|
getX |
int getX()
Returns the current x coordinate of the components origin.
public int getX()
-
Returns the current x coordinate of the components origin.
This method is preferable to writing
component.getBounds().x ,
or component.getLocation().x because it doesn't
cause any heap allocations.
- Returns:
- the current x coordinate of the components origin
- Since:
- 1.2
|
|
getY |
int getY()
Returns the current y coordinate of the components origin.
public int getY()
-
Returns the current y coordinate of the components origin.
This method is preferable to writing
component.getBounds().y ,
or component.getLocation().y because it
doesn't cause any heap allocations.
- Returns:
- the current y coordinate of the components origin
- Since:
- 1.2
|
|
inside |
boolean inside(int x,
int y)
Deprecated. As of JDK version 1.1,
replaced by contains(int, int).
@Deprecated
public boolean inside(int x,
int y)
Deprecated. As of JDK version 1.1,
replaced by contains(int, int).
|
|
invalidate |
void invalidate()
Invalidates this component and its ancestors.
public void invalidate()
-
Invalidates this component and its ancestors.
By default, all the ancestors of the component up to the top-most
container of the hierarchy are marked invalid. If the java.awt.smartInvalidate system property is set to true ,
invalidation stops on the nearest validate root of this component.
Marking a container invalid indicates that the container needs to
be laid out.
This method is called automatically when any layout-related information
changes (e.g. setting the bounds of the component, or adding the
component to a container).
This method might be called often, so it should work fast.
- Since:
- JDK1.0
- See Also:
validate() ,
doLayout() ,
LayoutManager ,
Container.isValidateRoot()
|
|
isMaximumSizeSet |
boolean isMaximumSizeSet()
Returns true if the maximum size has been set to a non-null
value otherwise returns false.
public boolean isMaximumSizeSet()
-
Returns true if the maximum size has been set to a non-null
value otherwise returns false.
- Returns:
- true if
maximumSize is non-null ,
false otherwise - Since:
- 1.5
|
|
isMinimumSizeSet |
boolean isMinimumSizeSet()
Returns whether or not setMinimumSize has been
invoked with a non-null value.
public boolean isMinimumSizeSet()
-
Returns whether or not setMinimumSize has been
invoked with a non-null value.
- Returns:
- true if
setMinimumSize has been invoked with a
non-null value. - Since:
- 1.5
|
|
isPreferredSizeSet |
boolean isPreferredSizeSet()
Returns true if the preferred size has been set to a
non-null value otherwise returns false.
public boolean isPreferredSizeSet()
-
Returns true if the preferred size has been set to a
non-null value otherwise returns false.
- Returns:
- true if
setPreferredSize has been invoked
with a non-null value. - Since:
- 1.5
|
|
isValid |
boolean isValid()
Determines whether this component is valid.
public boolean isValid()
-
Determines whether this component is valid. A component is valid
when it is correctly sized and positioned within its parent
container and all its children are also valid.
In order to account for peers' size requirements, components are invalidated
before they are first shown on the screen. By the time the parent container
is fully realized, all its components will be valid.
- Returns:
true if the component is valid, false
otherwise- Since:
- JDK1.0
- See Also:
validate() ,
invalidate()
|
|
layout |
void layout()
Deprecated. As of JDK version 1.1,
replaced by doLayout() .
@Deprecated
public void layout()
Deprecated. As of JDK version 1.1,
replaced by doLayout() .
|
|
locate |
Deprecated. As of JDK version 1.1,
replaced by getComponentAt(int, int).
@Deprecated
public Component locate(int x,
int y)
Deprecated. As of JDK version 1.1,
replaced by getComponentAt(int, int).
|
|
location |
Deprecated. As of JDK version 1.1,
replaced by getLocation() .
@Deprecated
public Point location()
Deprecated. As of JDK version 1.1,
replaced by getLocation() .
|
|
minimumSize |
Deprecated. As of JDK version 1.1,
replaced by getMinimumSize() .
Deprecated. As of JDK version 1.1,
replaced by getMinimumSize() .
|
|
move |
void move(int x,
int y)
Deprecated. As of JDK version 1.1,
replaced by setLocation(int, int) .
@Deprecated
public void move(int x,
int y)
Deprecated. As of JDK version 1.1,
replaced by setLocation(int, int) .
|
|
preferredSize |
Deprecated. As of JDK version 1.1,
replaced by getPreferredSize() .
Deprecated. As of JDK version 1.1,
replaced by getPreferredSize() .
|
|
reshape |
void reshape(int x,
int y,
int width,
int height)
Deprecated. As of JDK version 1.1,
replaced by setBounds(int, int, int, int) .
@Deprecated
public void reshape(int x,
int y,
int width,
int height)
Deprecated. As of JDK version 1.1,
replaced by setBounds(int, int, int, int) .
|
|
resize |
void resize(Dimension d)
Deprecated. As of JDK version 1.1,
replaced by setSize(Dimension) .
Deprecated. As of JDK version 1.1,
replaced by setSize(Dimension) .
|
|
resize |
void resize(int width,
int height)
Deprecated. As of JDK version 1.1,
replaced by setSize(int, int) .
@Deprecated
public void resize(int width,
int height)
Deprecated. As of JDK version 1.1,
replaced by setSize(int, int) .
|
|
revalidate |
void revalidate()
Revalidates the component hierarchy up to the nearest validate root.
public void revalidate()
-
Revalidates the component hierarchy up to the nearest validate root.
This method first invalidates the component hierarchy starting from this
component up to the nearest validate root. Afterwards, the component
hierarchy is validated starting from the nearest validate root.
This is a convenience method supposed to help application developers
avoid looking for validate roots manually. Basically, it's equivalent to
first calling the invalidate() method on this component, and
then calling the validate() method on the nearest validate
root.
- Since:
- 1.7
- See Also:
Container.isValidateRoot()
|
|
setBounds |
void setBounds(int x,
int y,
int width,
int height)
Moves and resizes this component.
public void setBounds(int x,
int y,
int width,
int height)
-
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 .
This method changes layout-related information, and therefore,
invalidates the component hierarchy.
- Parameters:
x - the new x-coordinate of this componenty - the new y-coordinate of this componentwidth - the new width of this componentheight - the new height of this
component- Since:
- JDK1.1
- See Also:
getBounds() ,
setLocation(int, int) ,
setLocation(Point) ,
setSize(int, int) ,
setSize(Dimension) ,
invalidate()
|
|
setBounds |
void setBounds(Rectangle r)
Moves and resizes this component to conform to the new
bounding 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
This method changes layout-related information, and therefore,
invalidates the component hierarchy.
- Parameters:
r - the new bounding rectangle for this component
- Throws:
java.lang.NullPointerException - if r is null - Since:
- JDK1.1
- See Also:
getBounds() ,
setLocation(int, int) ,
setLocation(Point) ,
setSize(int, int) ,
setSize(Dimension) ,
invalidate()
|
|
setLocation |
void setLocation(int x,
int y)
Moves this component to a new location.
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.
This method changes layout-related information, and therefore,
invalidates the component hierarchy.
- Parameters:
x - the x-coordinate of the new location's
top-left corner in the parent's coordinate spacey - the y-coordinate of the new location's
top-left corner in the parent's coordinate space- Since:
- JDK1.1
- See Also:
getLocation() ,
setBounds(int, int, int, int) ,
invalidate()
|
|
setLocation |
void setLocation(Point p)
Moves this component to a new location.
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.
This method changes layout-related information, and therefore,
invalidates the component hierarchy.
- Parameters:
p - the point defining the top-left corner
of the new location, given in the coordinate space of this
component's parent- Since:
- JDK1.1
- See Also:
getLocation() ,
setBounds(int, int, int, int) ,
invalidate()
|
|
setMaximumSize |
void setMaximumSize(Dimension maximumSize)
Sets the maximum size of this component to a constant
value.
public void setMaximumSize( Dimension maximumSize)
-
Sets the maximum size of this component to a constant
value. Subsequent calls to getMaximumSize will always
return this value. Setting the maximum size to null
restores the default behavior.
- Parameters:
maximumSize - a Dimension containing the
desired maximum allowable size- Since:
- 1.5
- See Also:
getMaximumSize() ,
isMaximumSizeSet()
|
|
setMinimumSize |
void setMinimumSize(Dimension minimumSize)
Sets the minimum size of this component to a constant
value.
public void setMinimumSize( Dimension minimumSize)
-
Sets the minimum size of this component to a constant
value. Subsequent calls to getMinimumSize will always
return this value. Setting the minimum size to null
restores the default behavior.
- Parameters:
minimumSize - the new minimum size of this component- Since:
- 1.5
- See Also:
getMinimumSize() ,
isMinimumSizeSet()
|
|
setPreferredSize |
void setPreferredSize(Dimension preferredSize)
Sets the preferred size of this component to a constant
value.
public void setPreferredSize( Dimension preferredSize)
-
Sets the preferred size of this component to a constant
value. Subsequent calls to getPreferredSize will always
return this value. Setting the preferred size to null
restores the default behavior.
- Parameters:
preferredSize - The new preferred size, or null- Since:
- 1.5
- See Also:
getPreferredSize() ,
isPreferredSizeSet()
|
|
setSize |
void setSize(Dimension d)
Resizes this component so that it has width d.width
and height d.height .
-
Resizes this component so that it has width d.width
and height d.height .
This method changes layout-related information, and therefore,
invalidates the component hierarchy.
- Parameters:
d - the dimension specifying the new size
of this component
- Throws:
java.lang.NullPointerException - if d is null - Since:
- JDK1.1
- See Also:
setSize(int, int) ,
setBounds(int, int, int, int) ,
invalidate()
|
|
setSize |
void setSize(int width,
int height)
Resizes this component so that it has width width
and height height .
public void setSize(int width,
int height)
-
Resizes this component so that it has width width
and height height .
This method changes layout-related information, and therefore,
invalidates the component hierarchy.
- Parameters:
width - the new width of this component in pixelsheight - the new height of this component in pixels- Since:
- JDK1.1
- See Also:
getSize() ,
setBounds(int, int, int, int) ,
invalidate()
|
|
size |
Deprecated. As of JDK version 1.1,
replaced by getSize() .
Deprecated. As of JDK version 1.1,
replaced by getSize() .
|
|
validate |
void validate()
Validates this component.
|