Insetspublic class Insets extends Object implements Cloneable, SerializableAn 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. |
Fields Summary |
---|
public int | topThe inset from the top.
This value is added to the Top of the rectangle
to yield a new location for the Top. | public int | leftThe 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 | bottomThe inset from the bottom.
This value is subtracted from the Bottom of the rectangle
to yield a new location for the Bottom. | public int | rightThe 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.
/* 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.Object | clone()Create a copy of this object.
try {
return super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
| public boolean | equals(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.
if (obj instanceof Insets) {
Insets insets = (Insets)obj;
return ((top == insets.top) && (left == insets.left) &&
(bottom == insets.bottom) && (right == insets.right));
}
return false;
| public int | hashCode()Returns the 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 void | initIDs()Initialize JNI field and method IDs
| public void | set(int top, int left, int bottom, int right)Set top, left, bottom, and right to the specified values
this.top = top;
this.left = left;
this.bottom = bottom;
this.right = right;
| public java.lang.String | toString()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 getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
|
|