home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / DefaultButtonModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  4.3 KB  |  227 lines

  1. package javax.swing;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.ItemEvent;
  6. import java.awt.event.ItemListener;
  7. import java.io.Serializable;
  8. import java.util.EventListener;
  9. import javax.swing.event.ChangeEvent;
  10. import javax.swing.event.ChangeListener;
  11. import javax.swing.event.EventListenerList;
  12.  
  13. public class DefaultButtonModel implements ButtonModel, Serializable {
  14.    protected int stateMask = 0;
  15.    protected String actionCommand = null;
  16.    protected ButtonGroup group = null;
  17.    protected int mnemonic = 0;
  18.    protected transient ChangeEvent changeEvent = null;
  19.    protected EventListenerList listenerList = new EventListenerList();
  20.    public static final int ARMED = 1;
  21.    public static final int SELECTED = 2;
  22.    public static final int PRESSED = 4;
  23.    public static final int ENABLED = 8;
  24.    public static final int ROLLOVER = 16;
  25.    // $FF: synthetic field
  26.    static Class class$javax$swing$event$ChangeListener;
  27.    // $FF: synthetic field
  28.    static Class class$java$awt$event$ActionListener;
  29.    // $FF: synthetic field
  30.    static Class class$java$awt$event$ItemListener;
  31.  
  32.    public DefaultButtonModel() {
  33.       this.stateMask = 0;
  34.       this.setEnabled(true);
  35.    }
  36.  
  37.    public void setActionCommand(String var1) {
  38.       this.actionCommand = var1;
  39.    }
  40.  
  41.    public String getActionCommand() {
  42.       return this.actionCommand;
  43.    }
  44.  
  45.    public boolean isArmed() {
  46.       return (this.stateMask & 1) != 0;
  47.    }
  48.  
  49.    public boolean isSelected() {
  50.       return (this.stateMask & 2) != 0;
  51.    }
  52.  
  53.    public boolean isEnabled() {
  54.       return (this.stateMask & 8) != 0;
  55.    }
  56.  
  57.    public boolean isPressed() {
  58.       return (this.stateMask & 4) != 0;
  59.    }
  60.  
  61.    public boolean isRollover() {
  62.       return (this.stateMask & 16) != 0;
  63.    }
  64.  
  65.    public void setArmed(boolean var1) {
  66.       if (this.isArmed() != var1 && this.isEnabled()) {
  67.          if (var1) {
  68.             this.stateMask |= 1;
  69.          } else {
  70.             this.stateMask &= -2;
  71.          }
  72.  
  73.          this.fireStateChanged();
  74.       }
  75.    }
  76.  
  77.    public void setEnabled(boolean var1) {
  78.       if (this.isEnabled() != var1) {
  79.          if (var1) {
  80.             this.stateMask |= 8;
  81.          } else {
  82.             this.stateMask &= -9;
  83.             this.stateMask &= -2;
  84.             this.stateMask &= -5;
  85.          }
  86.  
  87.          this.fireStateChanged();
  88.       }
  89.    }
  90.  
  91.    public void setSelected(boolean var1) {
  92.       if (this.isSelected() != var1) {
  93.          if (var1) {
  94.             this.stateMask |= 2;
  95.          } else {
  96.             this.stateMask &= -3;
  97.          }
  98.  
  99.          this.fireItemStateChanged(new ItemEvent(this, 701, this, var1 ? 1 : 2));
  100.          this.fireStateChanged();
  101.       }
  102.    }
  103.  
  104.    public void setPressed(boolean var1) {
  105.       if (this.isPressed() != var1 && this.isEnabled()) {
  106.          if (var1) {
  107.             this.stateMask |= 4;
  108.          } else {
  109.             this.stateMask &= -5;
  110.          }
  111.  
  112.          if (!this.isPressed() && this.isArmed()) {
  113.             this.fireActionPerformed(new ActionEvent(this, 1001, this.getActionCommand()));
  114.          }
  115.  
  116.          this.fireStateChanged();
  117.       }
  118.    }
  119.  
  120.    public void setRollover(boolean var1) {
  121.       if (this.isRollover() != var1 && this.isEnabled()) {
  122.          if (var1) {
  123.             this.stateMask |= 16;
  124.          } else {
  125.             this.stateMask &= -17;
  126.          }
  127.  
  128.          this.fireStateChanged();
  129.       }
  130.    }
  131.  
  132.    public void setMnemonic(int var1) {
  133.       this.mnemonic = var1;
  134.       this.fireStateChanged();
  135.    }
  136.  
  137.    public int getMnemonic() {
  138.       return this.mnemonic;
  139.    }
  140.  
  141.    public void addChangeListener(ChangeListener var1) {
  142.       this.listenerList.add(class$javax$swing$event$ChangeListener == null ? (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")) : class$javax$swing$event$ChangeListener, var1);
  143.    }
  144.  
  145.    public void removeChangeListener(ChangeListener var1) {
  146.       this.listenerList.remove(class$javax$swing$event$ChangeListener == null ? (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")) : class$javax$swing$event$ChangeListener, var1);
  147.    }
  148.  
  149.    protected void fireStateChanged() {
  150.       Object[] var1 = this.listenerList.getListenerList();
  151.  
  152.       for(int var2 = var1.length - 2; var2 >= 0; var2 -= 2) {
  153.          if (var1[var2] == (class$javax$swing$event$ChangeListener == null ? (class$javax$swing$event$ChangeListener = class$("javax.swing.event.ChangeListener")) : class$javax$swing$event$ChangeListener)) {
  154.             if (this.changeEvent == null) {
  155.                this.changeEvent = new ChangeEvent(this);
  156.             }
  157.  
  158.             ((ChangeListener)var1[var2 + 1]).stateChanged(this.changeEvent);
  159.          }
  160.       }
  161.  
  162.    }
  163.  
  164.    public void addActionListener(ActionListener var1) {
  165.       this.listenerList.add(class$java$awt$event$ActionListener == null ? (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")) : class$java$awt$event$ActionListener, var1);
  166.    }
  167.  
  168.    public void removeActionListener(ActionListener var1) {
  169.       this.listenerList.remove(class$java$awt$event$ActionListener == null ? (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")) : class$java$awt$event$ActionListener, var1);
  170.    }
  171.  
  172.    protected void fireActionPerformed(ActionEvent var1) {
  173.       Object[] var2 = this.listenerList.getListenerList();
  174.  
  175.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  176.          if (var2[var3] == (class$java$awt$event$ActionListener == null ? (class$java$awt$event$ActionListener = class$("java.awt.event.ActionListener")) : class$java$awt$event$ActionListener)) {
  177.             ((ActionListener)var2[var3 + 1]).actionPerformed(var1);
  178.          }
  179.       }
  180.  
  181.    }
  182.  
  183.    public void addItemListener(ItemListener var1) {
  184.       this.listenerList.add(class$java$awt$event$ItemListener == null ? (class$java$awt$event$ItemListener = class$("java.awt.event.ItemListener")) : class$java$awt$event$ItemListener, var1);
  185.    }
  186.  
  187.    public void removeItemListener(ItemListener var1) {
  188.       this.listenerList.remove(class$java$awt$event$ItemListener == null ? (class$java$awt$event$ItemListener = class$("java.awt.event.ItemListener")) : class$java$awt$event$ItemListener, var1);
  189.    }
  190.  
  191.    protected void fireItemStateChanged(ItemEvent var1) {
  192.       Object[] var2 = this.listenerList.getListenerList();
  193.  
  194.       for(int var3 = var2.length - 2; var3 >= 0; var3 -= 2) {
  195.          if (var2[var3] == (class$java$awt$event$ItemListener == null ? (class$java$awt$event$ItemListener = class$("java.awt.event.ItemListener")) : class$java$awt$event$ItemListener)) {
  196.             ((ItemListener)var2[var3 + 1]).itemStateChanged(var1);
  197.          }
  198.       }
  199.  
  200.    }
  201.  
  202.    public EventListener[] getListeners(Class var1) {
  203.       return this.listenerList.getListeners(var1);
  204.    }
  205.  
  206.    public Object[] getSelectedObjects() {
  207.       return null;
  208.    }
  209.  
  210.    public void setGroup(ButtonGroup var1) {
  211.       this.group = var1;
  212.    }
  213.  
  214.    public ButtonGroup getGroup() {
  215.       return this.group;
  216.    }
  217.  
  218.    // $FF: synthetic method
  219.    static Class class$(String var0) {
  220.       try {
  221.          return Class.forName(var0);
  222.       } catch (ClassNotFoundException var2) {
  223.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  224.       }
  225.    }
  226. }
  227.