FileDocCategorySizeDatePackage
Insets.javaAPI DocJava SE 5 API4938Fri Aug 26 14:56:46 BST 2005java.awt

Insets

public class Insets extends Object implements Cloneable, Serializable
An Insets object is a representation of the borders of a container. It specifies the space that a container must leave at each of its edges. The space can be a border, a blank space, or a title.
version
1.30, 12/19/03
author
Arthur van Hoff
author
Sami Shaio
see
java.awt.LayoutManager
see
java.awt.Container
since
JDK1.0

Fields Summary
public int
top
The inset from the top. This value is added to the Top of the rectangle to yield a new location for the Top.
public int
left
The inset from the left. This value is added to the Left of the rectangle to yield a new location for the Left edge.
public int
bottom
The inset from the bottom. This value is subtracted from the Bottom of the rectangle to yield a new location for the Bottom.
public int
right
The inset from the right. This value is subtracted from the Right of the rectangle to yield a new location for the Right edge.
private static final long
serialVersionUID
Constructors Summary
public Insets(int top, int left, int bottom, int right)
Creates and initializes a new Insets object with the specified top, left, bottom, and right insets.

param
top the inset from the top.
param
left the inset from the left.
param
bottom the inset from the bottom.
param
right the inset from the right.

  
     
        /* ensure that the necessary native libraries are loaded */
	Toolkit.loadLibraries();
        if (!GraphicsEnvironment.isHeadless()) {
            initIDs();
        }
    
	this.top = top;
	this.left = left;
	this.bottom = bottom;
	this.right = right;
    
Methods Summary
public java.lang.Objectclone()
Create a copy of this object.

return
a copy of this Insets object.

 
	try { 
	    return super.clone();
	} catch (CloneNotSupportedException e) { 
	    // this shouldn't happen, since we are Cloneable
	    throw new InternalError();
	}
    
public booleanequals(java.lang.Object obj)
Checks whether two insets objects are equal. Two instances of Insets are equal if the four integer values of the fields top, left, bottom, and right are all equal.

return
true if the two insets are equal; otherwise false.
since
JDK1.1

	if (obj instanceof Insets) {
	    Insets insets = (Insets)obj;
	    return ((top == insets.top) && (left == insets.left) &&
		    (bottom == insets.bottom) && (right == insets.right));
	}
	return false;
    
public inthashCode()
Returns the hash code for this Insets.

return
a hash code for this Insets.

        int sum1 = left + bottom;
        int sum2 = right + top;
        int val1 = sum1 * (sum1 + 1)/2 + left;
        int val2 = sum2 * (sum2 + 1)/2 + top;
        int sum3 = val1 + val2;
        return sum3 * (sum3 + 1)/2 + val2;
    
private static native voidinitIDs()
Initialize JNI field and method IDs

public voidset(int top, int left, int bottom, int right)
Set top, left, bottom, and right to the specified values

param
top the inset from the top.
param
left the inset from the left.
param
bottom the inset from the bottom.
param
right the inset from the right.
since
1.5

        this.top = top;
        this.left = left;
        this.bottom = bottom;
        this.right = right;
    
public java.lang.StringtoString()
Returns a string representation of this Insets object. 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.

return
a string representation of this Insets object.

	return getClass().getName() + "[top="  + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";