Dimension class encapsulates the width and
height of a component (in integer precision) in a single object.
The class is
associated with certain properties of components. Several methods
defined by the Component class and the
LayoutManager interface return a
Dimension object.
Normally the values of width
and height are non-negative integers.
The constructors that allow you to create a dimension do
not prevent you from setting a negative value for these properties.
If the value of width or height is
negative, the behavior of some methods defined by other objects is
undefined.
java.awt.Component , java.awt.LayoutManager
| Modifier and Type | Field and Description |
|---|---|
| public int | height
The height dimension; negative values can be used. |
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability. |
| public int | width
The width dimension; negative values can be used. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | Dimension(int
the specified width width, int the specified height height)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object obj)
Overrides java. Checks whether two dimension objects have equal values. |
| public double | getHeight()
Implements abstract java. Returns the height of this |
| public Dimension | Returns: the size of this dimension, a new instance ofDimension with the same width and heightGets the size of this |
| public double | getWidth()
Implements abstract java. Returns the width of this |
| public int | Returns: a hash code for thisDimensionOverrides java. Returns the hash code for this |
| private static native void | |
| public void | setSize(double
the new width for the width, double Dimension objectthe new height for the height)Dimension objectImplements abstract java. Sets the size of this |
| public void | |
| public void | setSize(int
the new width for this width, int Dimension objectthe new height for this height)Dimension objectSets the size of this |
| public String | Returns: a string representation of thisDimension
objectOverrides java. Returns a string representation of the values of this
|
| height | back to summary |
|---|---|
| public int height The height dimension; negative values can be used. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Use serialVersionUID from JDK 1.1 for interoperability. | |
| width | back to summary |
|---|---|
| public int width The width dimension; negative values can be used. | |
| Dimension | back to summary |
|---|---|
| public Dimension() Creates an instance of | |
| Dimension | back to summary |
|---|---|
| public Dimension(Dimension d) Creates an instance of
| |
| Dimension | back to summary |
|---|---|
| public Dimension(int width, int height) Constructs a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Checks whether two dimension objects have equal values. | |
| getHeight | back to summary |
|---|---|
| public double getHeight() Implements abstract java. Doc from java. Returns the height of this
| |
| getSize | back to summary |
|---|---|
| public Dimension getSize() Gets the size of this
| |
| getWidth | back to summary |
|---|---|
| public double getWidth() Implements abstract java. Doc from java. Returns the width of this
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code for this
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() Initialize JNI field and method IDs | |
| setSize | back to summary |
|---|---|
| public void setSize(double width, double height) Implements abstract java. Sets the size of this
| |
| setSize | back to summary |
|---|---|
| public void setSize(Dimension d) Sets the size of this
| |
| setSize | back to summary |
|---|---|
| public void setSize(int width, int height) Sets the size of this
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of the values of this
| |