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

  1. /*
  2.  * @(#)AdjustmentEvent.java    1.11 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.event;
  24.  
  25. import java.awt.Adjustable;
  26. import java.awt.AWTEvent;
  27. import java.awt.Event;
  28.  
  29. /**
  30.  * The adjustment event emitted by Adjustable objects.
  31.  * @see java.awt.Adjustable
  32.  * @see AdjustmentListener
  33.  *
  34.  * @version 1.11 01/27/97
  35.  * @author Amy Fowler
  36.  */
  37. public class AdjustmentEvent extends AWTEvent {
  38.  
  39.     /**
  40.      * Marks the first integer id for the range of adjustment event ids.
  41.      */
  42.     public static final int ADJUSTMENT_FIRST     = 601;
  43.  
  44.     /**
  45.      * Marks the last integer id for the range of adjustment event ids.
  46.      */
  47.     public static final int ADJUSTMENT_LAST     = 601;
  48.  
  49.     /**
  50.      * The adjustment value changed event.
  51.      */
  52.     public static final int ADJUSTMENT_VALUE_CHANGED = ADJUSTMENT_FIRST; //Event.SCROLL_LINE_UP
  53.  
  54.     /**
  55.      * The unit increment adjustment type.
  56.      */
  57.     public static final int UNIT_INCREMENT    = 1;
  58.  
  59.     /**
  60.      * The unit decrement adjustment type.
  61.      */
  62.     public static final int UNIT_DECREMENT    = 2;
  63.  
  64.     /**
  65.      * The block decrement adjustment type.
  66.      */
  67.     public static final int BLOCK_DECREMENT     = 3;
  68.  
  69.     /**
  70.      * The block increment adjustment type.
  71.      */
  72.     public static final int BLOCK_INCREMENT     = 4;
  73.  
  74.     /**
  75.      * The absolute tracking adjustment type.
  76.      */
  77.     public static final int TRACK            = 5;
  78.  
  79.     Adjustable adjustable;
  80.     int value;
  81.     int adjustmentType;
  82.  
  83.     /*
  84.      * JDK 1.1 serialVersionUID 
  85.      */
  86.      private static final long serialVersionUID = 5700290645205279921L;
  87.  
  88.     /**
  89.      * Constructs a AdjustmentEvent object with the specified Adjustable source,
  90.      * type, and value.
  91.      * @param source the Adjustable object where the event originated
  92.      * @id the event type
  93.      * @type the adjustment type 
  94.      * @value the current value of the adjustment
  95.      */
  96.     public AdjustmentEvent(Adjustable source, int id, int type, int value) {
  97.         super(source, id);
  98.     adjustable = source;
  99.         this.adjustmentType = type;
  100.     this.value = value;
  101.     }
  102.  
  103.     /**
  104.      * Returns the Adjustable object where this event originated.
  105.      */
  106.     public Adjustable getAdjustable() {
  107.         return adjustable;
  108.     }
  109.  
  110.     /**
  111.      * Returns the current value in the adjustment event.
  112.      */
  113.     public int getValue() {
  114.         return value;
  115.     }
  116.  
  117.     /**
  118.      * Returns the type of adjustment which caused the value changed
  119.      * event.
  120.      * @see UNIT_INCREMENT
  121.      * @see UNIT_DECREMENT
  122.      * @see BLOCK_INCREMENT
  123.      * @see BLOCK_DECREMENT
  124.      * @see TRACK
  125.      */
  126.     public int getAdjustmentType() {
  127.         return adjustmentType;
  128.     }
  129.  
  130.     public String paramString() {
  131.         String typeStr;
  132.         switch(id) {
  133.           case ADJUSTMENT_VALUE_CHANGED:
  134.               typeStr = "ADJUSTMENT_VALUE_CHANGED";
  135.               break;
  136.           default:
  137.               typeStr = "unknown type";
  138.         }
  139.         String adjTypeStr;
  140.         switch(adjustmentType) {
  141.           case UNIT_INCREMENT:
  142.               adjTypeStr = "UNIT_INCREMENT";
  143.               break;
  144.           case UNIT_DECREMENT:
  145.               adjTypeStr = "UNIT_DECREMENT";
  146.               break;
  147.           case BLOCK_INCREMENT:
  148.               adjTypeStr = "BLOCK_INCREMENT";
  149.               break;
  150.           case BLOCK_DECREMENT:
  151.               adjTypeStr = "BLOCK_DECREMENT";
  152.               break;
  153.           case TRACK:
  154.               adjTypeStr = "TRACK";
  155.               break;
  156.           default:
  157.               adjTypeStr = "unknown type";
  158.         }
  159.         return typeStr + ",adjType="+adjTypeStr + ",value="+value;
  160.     }
  161. }
  162.