home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / awt / Insets.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  4.2 KB  |  147 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Insets.java    1.20 98/09/21
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt;
  16.  
  17. /**
  18.  * An <code>Insets</code> object is a representation of the borders 
  19.  * of a container. It specifies the space that a container must leave 
  20.  * at each of its edges. The space can be a border, a blank space, or 
  21.  * a title. 
  22.  *
  23.  * @version     1.20, 09/21/98
  24.  * @author     Arthur van Hoff
  25.  * @author     Sami Shaio
  26.  * @see         java.awt.LayoutManager
  27.  * @see         java.awt.Container
  28.  * @since       JDK1.0
  29.  */
  30. public class Insets implements Cloneable, java.io.Serializable {
  31.  
  32.     /**
  33.      * The inset from the top.
  34.      * This value is added to the Top of the rectangle
  35.      * to yield a new location for the Top.
  36.      *
  37.      * @serial
  38.      * @see clone()
  39.      */
  40.     public int top;
  41.  
  42.     /**
  43.      * The inset from the left.
  44.      * This value is added to the left of the rectangle
  45.      * to yield a new location for the left edge.
  46.      *
  47.      * @serial
  48.      * @see clone()
  49.      */
  50.     public int left;
  51.  
  52.     /**
  53.      * The inset from the bottom.
  54.      * This value is added to the Bottom of the rectangle
  55.      * to yield a new location for the Bottom.
  56.      *
  57.      * @serial
  58.      * @see clone()
  59.      */
  60.     public int bottom;
  61.  
  62.     /**
  63.      * The inset from the right.
  64.      * This value is added to the Right of the rectangle
  65.      * to yield a new location for the Right edge.
  66.      *
  67.      * @serial
  68.      * @see clone()
  69.      */
  70.     public int right;
  71.  
  72.     /*
  73.      * JDK 1.1 serialVersionUID 
  74.      */
  75.     private static final long serialVersionUID = -2272572637695466749L;
  76.   
  77.     static {
  78.         /* ensure that the necessary native libraries are loaded */
  79.     Toolkit.loadLibraries();
  80.     initIDs();
  81.     }
  82.  
  83.     /**
  84.      * Creates and initializes a new <code>Insets</code> object with the 
  85.      * specified top, left, bottom, and right insets. 
  86.      * @param       top   the inset from the top.
  87.      * @param       left   the inset from the left.
  88.      * @param       bottom   the inset from the bottom.
  89.      * @param       right   the inset from the right.
  90.      */
  91.     public Insets(int top, int left, int bottom, int right) {
  92.     this.top = top;
  93.     this.left = left;
  94.     this.bottom = bottom;
  95.     this.right = right;
  96.     }
  97.  
  98.     /**
  99.      * Checks whether two insets objects are equal. Two instances 
  100.      * of <code>Insets</code> are equal if the four integer values
  101.      * of the fields <code>top</code>, <code>left</code>, 
  102.      * <code>bottom</code>, and <code>right</code> are all equal.
  103.      * @return      <code>true</code> if the two insets are equal;
  104.      *                          otherwise <code>false</code>.
  105.      * @since       JDK1.1
  106.      */
  107.     public boolean equals(Object obj) {
  108.     if (obj instanceof Insets) {
  109.         Insets insets = (Insets)obj;
  110.         return ((top == insets.top) && (left == insets.left) &&
  111.             (bottom == insets.bottom) && (right == insets.right));
  112.     }
  113.     return false;
  114.     }
  115.  
  116.     /**
  117.      * Returns a string representation of this <code>Insets</code> object. 
  118.      * This method is intended to be used only for debugging purposes, and 
  119.      * the content and format of the returned string may vary between 
  120.      * implementations. The returned string may be empty but may not be 
  121.      * <code>null</code>.
  122.      * 
  123.      * @return  a string representation of this <code>Insets</code> object.
  124.      */
  125.     public String toString() {
  126.     return getClass().getName() + "[top="  + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
  127.     }
  128.  
  129.     /**
  130.      * Create a copy of this object.
  131.      * @return     a copy of this <code>Insets</code> object.
  132.      */
  133.     public Object clone() { 
  134.     try { 
  135.         return super.clone();
  136.     } catch (CloneNotSupportedException e) { 
  137.         // this shouldn't happen, since we are Cloneable
  138.         throw new InternalError();
  139.     }
  140.     }
  141.     /**
  142.      * Initialize JNI field and method IDs
  143.      */
  144.     private static native void initIDs();
  145.  
  146. }
  147.