home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / Insets.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.2 KB  |  113 lines

  1. /*
  2.  * @(#)Insets.java    1.15 98/03/18
  3.  *
  4.  * Copyright 1995-1997 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.15, 03/18/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.      */
  35.     public int top;
  36.  
  37.     /**
  38.      * The inset from the left.
  39.      */
  40.     public int left;
  41.  
  42.     /**
  43.      * The inset from the bottom.
  44.      */
  45.     public int bottom;
  46.  
  47.     /**
  48.      * The inset from the right.
  49.      */
  50.     public int right;
  51.  
  52.     /*
  53.      * JDK 1.1 serialVersionUID 
  54.      */
  55.     private static final long serialVersionUID = -2272572637695466749L;
  56.  
  57.     /**
  58.      * Creates and initializes a new <code>Insets</code> object with the 
  59.      * specified top, left, bottom, and right insets. 
  60.      * @param       top   the inset from the top.
  61.      * @param       left   the inset from the left.
  62.      * @param       bottom   the inset from the bottom.
  63.      * @param       right   the inset from the right.
  64.      */
  65.     public Insets(int top, int left, int bottom, int right) {
  66.     this.top = top;
  67.     this.left = left;
  68.     this.bottom = bottom;
  69.     this.right = right;
  70.     }
  71.  
  72.     /**
  73.      * Checks whether two insets objects are equal. Two instances 
  74.      * of <code>Insets</code> are equal if the four integer values
  75.      * of the fields <code>top</code>, <code>left</code>, 
  76.      * <code>bottom</code>, and <code>right</code> are all equal.
  77.      * @return      <code>true</code> if the two insets are equal;
  78.      *                          otherwise <code>false</code>.
  79.      * @since       JDK1.1
  80.      */
  81.     public boolean equals(Object obj) {
  82.     if (obj instanceof Insets) {
  83.         Insets insets = (Insets)obj;
  84.         return ((top == insets.top) && (left == insets.left) &&
  85.             (bottom == insets.bottom) && (right == insets.right));
  86.     }
  87.     return false;
  88.     }
  89.  
  90.     /**
  91.      * Returns a <code>String</code> object representing this 
  92.      * <code>Insets</code> object's values.
  93.      * @return    a string representation of this <code>Insets</code> object, 
  94.      *                           including the values of its member fields.
  95.      */
  96.     public String toString() {
  97.     return getClass().getName() + "[top="  + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
  98.     }
  99.  
  100.     /**
  101.      * Create a copy of this object.
  102.      * @return     a copy of this <code>Insets</code> object.
  103.      */
  104.     public Object clone() { 
  105.     try { 
  106.         return super.clone();
  107.     } catch (CloneNotSupportedException e) { 
  108.         // this shouldn't happen, since we are Cloneable
  109.         throw new InternalError();
  110.     }
  111.     }
  112. }
  113.