home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / Insets.java < prev    next >
Text File  |  1997-10-01  |  4KB  |  128 lines

  1. /*
  2.  * @(#)Insets.java    1.13 97/06/16
  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.  * An <code>Insets</code> object is a representation of the borders 
  27.  * of a container. It specifies the space that a container must leave 
  28.  * at each of its edges. The space can be a border, a blank space, or 
  29.  * a title. 
  30.  *
  31.  * @version     1.13, 06/16/97
  32.  * @author     Arthur van Hoff
  33.  * @author     Sami Shaio
  34.  * @see         java.awt.LayoutManager
  35.  * @see         java.awt.Container
  36.  * @since       JDK1.0
  37.  */
  38. public class Insets implements Cloneable, java.io.Serializable {
  39.  
  40.     /**
  41.      * The inset from the top.
  42.      * @since JDK1.0
  43.      */
  44.     public int top;
  45.  
  46.     /**
  47.      * The inset from the left.
  48.      * @since JDK1.0
  49.      */
  50.     public int left;
  51.  
  52.     /**
  53.      * The inset from the bottom.
  54.      * @since JDK1.0
  55.      */
  56.     public int bottom;
  57.  
  58.     /**
  59.      * The inset from the right.
  60.      * @since JDK1.0
  61.      */
  62.     public int right;
  63.  
  64.     /*
  65.      * JDK 1.1 serialVersionUID 
  66.      */
  67.     private static final long serialVersionUID = -2272572637695466749L;
  68.  
  69.     /**
  70.      * Creates and initializes a new <code>Insets</code> object with the 
  71.      * specified top, left, bottom, and right insets. 
  72.      * @param       top   the inset from the top.
  73.      * @param       left   the inset from the left.
  74.      * @param       bottom   the inset from the bottom.
  75.      * @param       right   the inset from the right.
  76.      * @since       JDK1.0
  77.      */
  78.     public Insets(int top, int left, int bottom, int right) {
  79.     this.top = top;
  80.     this.left = left;
  81.     this.bottom = bottom;
  82.     this.right = right;
  83.     }
  84.  
  85.     /**
  86.      * Checks whether two insets objects are equal. Two instances 
  87.      * of <code>Insets</code> are equal if the four integer values
  88.      * of the fields <code>top</code>, <code>left</code>, 
  89.      * <code>bottom</code>, and <code>right</code> are all equal.
  90.      * @return      <code>true</code> if the two insets are equal;
  91.      *                          otherwise <code>false</code>.
  92.      * @since       JDK1.1
  93.      */
  94.     public boolean equals(Object obj) {
  95.     if (obj instanceof Insets) {
  96.         Insets insets = (Insets)obj;
  97.         return ((top == insets.top) && (left == insets.left) &&
  98.             (bottom == insets.bottom) && (right == insets.right));
  99.     }
  100.     return false;
  101.     }
  102.  
  103.     /**
  104.      * Returns a <code>String</code> object representing this 
  105.      * <code>Insets</code> object's values.
  106.      * @return    a string representation of this <code>Insets</code> object, 
  107.      *                           including the values of its member fields.
  108.      * @since     JDK1.0
  109.      */
  110.     public String toString() {
  111.     return getClass().getName() + "[top="  + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]";
  112.     }
  113.  
  114.     /**
  115.      * Create a copy of this object.
  116.      * @return     a copy of this <code>Insets</code> object.
  117.      * @since      JDK1.0
  118.      */
  119.     public Object clone() { 
  120.     try { 
  121.         return super.clone();
  122.     } catch (CloneNotSupportedException e) { 
  123.         // this shouldn't happen, since we are Cloneable
  124.         throw new InternalError();
  125.     }
  126.     }
  127. }
  128.