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

  1. /*
  2.  * @(#)Cursor.java    1.5 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. package java.awt;
  23.  
  24.  
  25. /**
  26.  * A class to encapsulate the bitmap representation of the mouse cursor.
  27.  *
  28.  * @see Component#setCursor
  29.  * @version     1.5, 01/27/97
  30.  * @author     Amy Fowler
  31.  */
  32. public class Cursor implements java.io.Serializable {
  33.  
  34.     /**
  35.      * The default cursor type (gets set if no cursor is defined).
  36.      */
  37.     public static final int    DEFAULT_CURSOR           = 0;
  38.  
  39.     /**
  40.      * The crosshair cursor type.
  41.      */
  42.     public static final int    CROSSHAIR_CURSOR         = 1;
  43.  
  44.     /**
  45.      * The text cursor type.
  46.      */
  47.     public static final int    TEXT_CURSOR              = 2;
  48.  
  49.     /**
  50.      * The wait cursor type.
  51.      */
  52.     public static final int    WAIT_CURSOR             = 3;
  53.  
  54.     /**
  55.      * The south-west-resize cursor type.
  56.      */
  57.     public static final int    SW_RESIZE_CURSOR         = 4;
  58.  
  59.     /**
  60.      * The south-east-resize cursor type.
  61.      */
  62.     public static final int    SE_RESIZE_CURSOR         = 5;
  63.  
  64.     /**
  65.      * The north-west-resize cursor type.
  66.      */
  67.     public static final int    NW_RESIZE_CURSOR        = 6;
  68.  
  69.     /**
  70.      * The north-east-resize cursor type.
  71.      */
  72.     public static final int    NE_RESIZE_CURSOR         = 7;
  73.  
  74.     /**
  75.      * The north-resize cursor type.
  76.      */
  77.     public static final int    N_RESIZE_CURSOR         = 8;
  78.  
  79.     /**
  80.      * The south-resize cursor type.
  81.      */
  82.     public static final int    S_RESIZE_CURSOR         = 9;
  83.  
  84.     /**
  85.      * The west-resize cursor type.
  86.      */
  87.     public static final int    W_RESIZE_CURSOR             = 10;
  88.  
  89.     /**
  90.      * The east-resize cursor type.
  91.      */
  92.     public static final int    E_RESIZE_CURSOR            = 11;
  93.  
  94.     /**
  95.      * The hand cursor type.
  96.      */
  97.     public static final int    HAND_CURSOR            = 12;
  98.  
  99.     /**
  100.      * The move cursor type.
  101.      */
  102.     public static final int    MOVE_CURSOR            = 13;
  103.  
  104.     protected static Cursor predefined[] = new Cursor[14];
  105.  
  106.     int type = DEFAULT_CURSOR;
  107.  
  108.      /*
  109.       * JDK 1.1 serialVersionUID 
  110.       */
  111.      private static final long serialVersionUID = 8028237497568985504L;
  112.  
  113.     /**
  114.      * Returns a cursor object with the specified predefined type.
  115.      * @param type the type of predefined cursor
  116.      */
  117.     static public Cursor getPredefinedCursor(int type) {
  118.     if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
  119.         throw new IllegalArgumentException("illegal cursor type");
  120.     }
  121.     if (predefined[type] == null) {
  122.         predefined[type] = new Cursor(type);
  123.     }
  124.     return predefined[type];
  125.     }
  126.  
  127.     /**
  128.      * Return the system default cursor.
  129.      */
  130.     static public Cursor getDefaultCursor() {
  131.         return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
  132.     }
  133.  
  134.     /**
  135.      * Creates a new cursor object with the specified type.
  136.      * @param type the type of cursor
  137.      */
  138.     public Cursor(int type) {
  139.     if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
  140.         throw new IllegalArgumentException("illegal cursor type");
  141.     }
  142.     this.type = type;
  143.     }
  144.  
  145.     /**
  146.      * Returns the type for this cursor.
  147.      */
  148.     public int getType() {
  149.     return type;
  150.     }    
  151.     
  152. }
  153.