public class java.awt
Dimension


Show All Login
Java SE 6
  
Extends: Dimension2D
Implements: Serializable
Extended by: DimensionUIResource
Details
The 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.
version1.34, 02/24/06
since1.0
See also java.awt.Component, java.awt.LayoutManager


Fields
public int width Details
The width dimension; negative values can be used.
serial
since1.0
See also getSize, setSize
public int height Details
The height dimension; negative values can be used.
serial
since1.0
See also getSize, setSize

Constructors
public Dimension()
Creates an instance of Dimension with a width of zero and a height of zero.
public Dimension(Dimension d) Details
Creates an instance of Dimension whose width and height are the same as for the specified dimension.
dthe specified dimension for the width and height values
public Dimension(int width, int height) Details
Constructs a Dimension and initializes it to the specified width and specified height.
widththe specified width
heightthe specified height

Methods
public boolean equals(Object obj)
Checks whether two dimension objects have equal values.
public int hashCode() Details
Returns the hash code for this Dimension.
returna hash code for this Dimension
public String toString() Details
Returns a string representation of the values of this Dimension object's height and width fields. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
returna string representation of this Dimension object

Properties
public double getHeight() Details
Returns the height of this Dimension in double precision.
since1.2
public void setSize(double width, double height) Details
Sets the size of this Dimension object to the specified width and height in double precision. Note that if width or height are larger than Integer.MAX_VALUE, they will be reset to Integer.MAX_VALUE.
widththe new width for the Dimension object
heightthe new height for the Dimension object
since1.2
public void setSize(Dimension d) Details
Sets the size of this Dimension object to the specified size. This method is included for completeness, to parallel the setSize method defined by Component.
dthe new size for this Dimension object
since1.1
See also getSize, setSize
public void setSize(int width, int height) Details
Sets the size of this Dimension object to the specified width and height. This method is included for completeness, to parallel the setSize method defined by Component.
widththe new width for this Dimension object
heightthe new height for this Dimension object
since1.1
See also getSize, setSize
public Dimension getSize() Details
Gets the size of this Dimension object. This method is included for completeness, to parallel the getSize method defined by Component.
returnthe size of this dimension, a new instance of Dimension with the same width and height
since1.1
See also setSize, getSize
public double getWidth() Details
Returns the width of this Dimension in double precision.
since1.2