Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Point

Fields , Constructors , Methods

public  class  java.awt.Point
    extends  java.lang.Object  
{
        // Fields
    public int x;	
    public int y;	

        // Constructors
    public Point(int  x, int  y);	

        // Methods
    public boolean equals(Object  obj);	
    public int hashCode();	
    public void move(int  x, int  y);	
    public String toString();	
    public void translate(int  dx, int  dy);	
}

A point represents an (x,y) coordinate.


Fields


x

public int x 

The x coordinate.


y

public int y 

The y coordinate.


Constructors


Point

public Point(int  x, int  y) 

Constructs and initializes a point to the specified (x,y) coordinate.

ParameterDescription
x the x coordinate
y the y coordinate


Methods


equals

public boolean equals(Object  obj) 

The result is true if and only if the argument is not null and is a Point object that has the same x and y coordinates as this object.

Return Value:

Returns true if the objects are the same; false otherwise.

ParameterDescription
obj the object to compare with.

Overrides:

equals in class Object .


hashCode

public int hashCode() 

Return Value:

Returns a hash code value for this point.

Overrides:

hashCode in class Object .


move

public void move(int  x, int  y) 

Modifies this point so that it now represents the (x,y) coordinates indicated.

ParameterDescription
x the new x coordinate
y the new y coordinate


toString

public String toString() 

Return Value:

Returns a string representation of this point.

Overrides:

toString in class Object .


translate

public void translate(int  dx, int  dy) 

Translates this point by dx to the right and dy downward so that it now represents the point (x+dx, y+dy), where it had been representing the point (x,y).

ParameterDescription
dx the amount to move this point to the right
dy the amount to move this point downward



Top© 1996 Sun Microsystems, Inc. All rights reserved.