home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / CFJava.cab / CFJavaRuntime.cab / netscape / application / KeyStroke.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-10-01  |  2.4 KB  |  92 lines

  1. package netscape.application;
  2.  
  3. import netscape.util.ClassInfo;
  4. import netscape.util.Codable;
  5. import netscape.util.CodingException;
  6. import netscape.util.Decoder;
  7. import netscape.util.Encoder;
  8.  
  9. public class KeyStroke implements Codable {
  10.    int key;
  11.    int modifiers;
  12.    static final String KEY_KEY = "key";
  13.    static final String MODIFIERS_KEY = "modifiers";
  14.  
  15.    public KeyStroke() {
  16.    }
  17.  
  18.    public KeyStroke(int var1, int var2) {
  19.       this.key = var1;
  20.       this.modifiers = var2;
  21.    }
  22.  
  23.    public KeyStroke(KeyEvent var1) {
  24.       this(var1.key, var1.modifiers);
  25.    }
  26.  
  27.    public int key() {
  28.       return this.key;
  29.    }
  30.  
  31.    public int modifiers() {
  32.       return this.modifiers;
  33.    }
  34.  
  35.    public boolean equals(Object var1) {
  36.       if (!(var1 instanceof KeyStroke)) {
  37.          return false;
  38.       } else if (this.key == ((KeyStroke)var1).key && this.modifiers == ((KeyStroke)var1).modifiers) {
  39.          return true;
  40.       } else if ((this.modifiers & 2) > 0) {
  41.          int var2 = ((KeyStroke)var1).key() + 64;
  42.          int var3 = this.key;
  43.          if (var2 >= 97 && var2 <= 122) {
  44.             var2 -= 32;
  45.          }
  46.  
  47.          if (var3 >= 97 && var3 <= 122) {
  48.             var3 -= 32;
  49.          }
  50.  
  51.          return var2 == var3;
  52.       } else {
  53.          return false;
  54.       }
  55.    }
  56.  
  57.    public boolean matchesKeyEvent(KeyEvent var1) {
  58.       if (var1 == null) {
  59.          return false;
  60.       } else {
  61.          return var1.type == -11 && var1.key == this.key && var1.modifiers == this.modifiers;
  62.       }
  63.    }
  64.  
  65.    public int hashCode() {
  66.       return ("" + this).hashCode();
  67.    }
  68.  
  69.    public String toString() {
  70.       return "KeyStroke (" + this.key + "," + this.modifiers + ")";
  71.    }
  72.  
  73.    public void describeClassInfo(ClassInfo var1) {
  74.       var1.addClass("netscape.application.KeyStroke", 1);
  75.       var1.addField("key", (byte)8);
  76.       var1.addField("modifiers", (byte)8);
  77.    }
  78.  
  79.    public void encode(Encoder var1) throws CodingException {
  80.       var1.encodeInt("key", this.key);
  81.       var1.encodeInt("modifiers", this.modifiers);
  82.    }
  83.  
  84.    public void decode(Decoder var1) throws CodingException {
  85.       this.key = var1.decodeInt("key");
  86.       this.modifiers = var1.decodeInt("modifiers");
  87.    }
  88.  
  89.    public void finishDecoding() throws CodingException {
  90.    }
  91. }
  92.