home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 July & August / Pcwk78a98.iso / Internet / Javadraw / DATA.Z / ActionEvent.java < prev    next >
Text File  |  1997-08-30  |  4KB  |  131 lines

  1. /*
  2.  * @(#)ActionEvent.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.event;
  24.  
  25. import java.awt.AWTEvent;
  26. import java.awt.Event;
  27.  
  28. /**
  29.  * The action semantic event.
  30.  * @see ActionListener
  31.  *
  32.  * @version 1.12 01/27/97
  33.  * @author Carl Quinn
  34.  */
  35. public class ActionEvent extends AWTEvent {
  36.  
  37.     /**
  38.      * The shift modifier constant.
  39.      */
  40.     public static final int SHIFT_MASK        = Event.SHIFT_MASK;
  41.  
  42.     /**
  43.      * The control modifier constant.
  44.      */
  45.     public static final int CTRL_MASK        = Event.CTRL_MASK;
  46.  
  47.     /** 
  48.      * The meta modifier constant.
  49.      */
  50.     public static final int META_MASK        = Event.META_MASK;
  51.  
  52.     /** 
  53.      * The alt modifier constant.
  54.      */
  55.     public static final int ALT_MASK        = Event.ALT_MASK;
  56.  
  57.  
  58.     /**
  59.      * Marks the first integer id for the range of action event ids.
  60.      */
  61.     public static final int ACTION_FIRST        = 1001;
  62.  
  63.     /**
  64.      * Marks the last integer id for the range of action event ids.
  65.      */
  66.     public static final int ACTION_LAST                = 1001;
  67.  
  68.     /**
  69.      * An action performed event type.
  70.      */
  71.     public static final int ACTION_PERFORMED    = ACTION_FIRST; //Event.ACTION_EVENT
  72.  
  73.     String actionCommand;
  74.     int modifiers;
  75.  
  76.     /*
  77.      * JDK 1.1 serialVersionUID 
  78.      */
  79.     private static final long serialVersionUID = -7671078796273832149L;
  80.  
  81.     /**
  82.      * Constructs an ActionEvent object with the specified source object.
  83.      * @param source the object where the event originated
  84.      * @param id the type of event
  85.      * @param command the command string for this action event
  86.      */
  87.     public ActionEvent(Object source, int id, String command) {
  88.         this(source, id, command, 0);
  89.     }
  90.  
  91.     /**
  92.      * Constructs an ActionEvent object with the specified source object.
  93.      * @param source the object where the event originated
  94.      * @param id the type of event
  95.      * @param command the command string for this action event
  96.      * @param modifiers the modifiers held down during this action
  97.      */
  98.     public ActionEvent(Object source, int id, String command, int modifiers) {
  99.         super(source, id);
  100.         this.actionCommand = command;
  101.         this.modifiers = modifiers;
  102.     }
  103.  
  104.     /**
  105.      * Returns the command name associated with this action.
  106.      */
  107.     public String getActionCommand() {
  108.         return actionCommand;
  109.     }
  110.  
  111.     /**
  112.      * Returns the modifiers held down during this action event.
  113.      */
  114.     public int getModifiers() {
  115.         return modifiers;
  116.     }
  117.  
  118.     public String paramString() {
  119.         String typeStr;
  120.         switch(id) {
  121.           case ACTION_PERFORMED:
  122.               typeStr = "ACTION_PERFORMED";
  123.               break;
  124.           default:
  125.               typeStr = "unknown type";
  126.         }
  127.         return typeStr + ",cmd="+actionCommand;
  128.     }
  129.  
  130. }
  131.