Java AWT

Previous Chapter 19
java.awt Reference
Next
 

Dimension

Name

Dimension

[Graphic: Figure from the text]

Description

The Dimension class encapsulates width and height in a single object.

Class Definition

public class java.awt.Dimension
    extends java.lang.Object
    implements java.io.Serializable {
  
  // Variables
  public int height;
  public int width;
  
  // Constructors
  public Dimension();
  public Dimension (int width, int height);
  public Dimension (Dimension d);
  
  // Instance Methods
  public boolean equals (Object obj); (New)
  public Dimension getSize(); (New)
  public void setSize (Dimension d); (New)
  public void setSize (int width, int height); (New)
  public String toString();
}

Variables

height

public int height

The height of the Dimension.

width

public int width

The width of the Dimension.

Constructors

Dimension

public Dimension()

Description

Constructs an empty Dimension object.

public Dimension (int width, int height)

Parameters

width

Initial width of the object

height

Initial height of the object

Description

Constructs a Dimension object with an initial dimension of width x height.

public Dimension (Dimension d)

Parameters

d

Initial dimensions of the object

Description

Constructs a Dimension object that is a clone of d.

Instance Methods

equals

public boolean equals (Object obj) (New)

Parameters

obj

The object to compare.

Returns

true if this Dimension is equivalent to obj; false otherwise.

Overrides

Object.equals(Object)

Description

Compares two Dimension instances.

getSize

public Dimension getSize() (New)

Returns

The size of the Dimension.

setSize

public void setSize (Dimension d) (New)

Parameters

d

The new size.

Description

Changes the size of the Dimension.

public void setSize (int width, int height) (New)

Parameters

width

The new width.

height

The new height.

Description

Changes the size of the Dimension.

toString

public String toString()

Returns

A string representation of the Dimension object.

Overrides

Object.toString()

See Also

Object, String, Serializable


Previous Home Next
Dialog Book Index Event

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java
This HTML Help has been published using the chm2web software.