home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 February / VPR9802A.ISO / APP_DEMO / VC / MAIN.BIN / Insets.java < prev    next >
Text File  |  1997-10-27  |  3KB  |  106 lines

  1. /*
  2.  * @(#)Insets.java    1.12 97/01/27
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.awt;
  24.  
  25. /**
  26.  * The insets of a container.
  27.  * This class is used to layout containers.
  28.  *
  29.  * @see LayoutManager
  30.  * @see Container
  31.  *
  32.  * @version     1.12, 01/27/97
  33.  * @author     Arthur van Hoff
  34.  * @author     Sami Shaio
  35.  */
  36. public class Insets implements Cloneable, java.io.Serializable {
  37.  
  38.     /**
  39.      * The inset from the top.
  40.      */
  41.     public int top;
  42.  
  43.     /**
  44.      * The inset from the left.
  45.      */
  46.     public int left;
  47.  
  48.     /**
  49.      * The inset from the bottom.
  50.      */
  51.     public int bottom;
  52.  
  53.     /**
  54.      * The inset from the right.
  55.      */
  56.     public int right;
  57.  
  58.     /*
  59.      * JDK 1.1 serialVersionUID 
  60.      */
  61.     private static final long serialVersionUID = -2272572637695466749L;
  62.  
  63.     /**
  64.      * Constructs and initializes a new Inset with the specified top,
  65.      * left, bottom, and right insets.
  66.      * @param top the inset from the top
  67.      * @param left the inset from the left
  68.      * @param bottom the inset from the bottom
  69.      * @param right the inset from the right
  70.      */
  71.     public Insets(int top, int left, int bottom, int right) {
  72.     this.top = top;
  73.     this.left = left;
  74.     this.bottom = bottom;
  75.     this.right = right;
  76.     }
  77.  
  78.     /**
  79.      * Checks whether two insets objects are equal.
  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 String object representing this Inset's values.
  92.      */
  93.     public String toString() {
  94.     return getClass().getName() + "[top="  + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
  95.     }
  96.  
  97.     public Object clone() { 
  98.     try { 
  99.         return super.clone();
  100.     } catch (CloneNotSupportedException e) { 
  101.         // this shouldn't happen, since we are Cloneable
  102.         throw new InternalError();
  103.     }
  104.     }
  105. }
  106.