home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Main.bin / Cursor.java < prev    next >
Text File  |  1998-09-22  |  4KB  |  145 lines

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