home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIPHEFT062001.ISO / browser / nc32lyc / comm.z / java40.jar / java / awt / Button.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-08-15  |  3.3 KB  |  115 lines

  1. package java.awt;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.peer.ButtonPeer;
  6. import java.io.IOException;
  7. import java.io.ObjectInputStream;
  8. import java.io.ObjectOutputStream;
  9.  
  10. public class Button extends Component {
  11.    String label;
  12.    String actionCommand;
  13.    transient ActionListener actionListener;
  14.    private static final String base = "button";
  15.    private static int nameCounter;
  16.    private static final long serialVersionUID = -8774683716313001058L;
  17.    private int buttonSerializedDataVersion;
  18.  
  19.    public Button() {
  20.       this("");
  21.    }
  22.  
  23.    public Button(String var1) {
  24.       this.buttonSerializedDataVersion = 1;
  25.       super.name = "button" + nameCounter++;
  26.       this.label = var1;
  27.    }
  28.  
  29.    public void addNotify() {
  30.       if (super.peer == null) {
  31.          super.peer = ((Component)this).getToolkit().createButton(this);
  32.       }
  33.  
  34.       super.addNotify();
  35.    }
  36.  
  37.    public String getLabel() {
  38.       return this.label;
  39.    }
  40.  
  41.    public synchronized void setLabel(String var1) {
  42.       this.label = var1;
  43.       ButtonPeer var2 = (ButtonPeer)super.peer;
  44.       if (var2 != null) {
  45.          var2.setLabel(var1);
  46.       }
  47.  
  48.    }
  49.  
  50.    public void setActionCommand(String var1) {
  51.       this.actionCommand = var1;
  52.    }
  53.  
  54.    public String getActionCommand() {
  55.       return this.actionCommand == null ? this.label : this.actionCommand;
  56.    }
  57.  
  58.    public synchronized void addActionListener(ActionListener var1) {
  59.       this.actionListener = AWTEventMulticaster.add(this.actionListener, var1);
  60.       super.newEventsOnly = true;
  61.    }
  62.  
  63.    public synchronized void removeActionListener(ActionListener var1) {
  64.       this.actionListener = AWTEventMulticaster.remove(this.actionListener, var1);
  65.    }
  66.  
  67.    boolean eventEnabled(AWTEvent var1) {
  68.       if (var1.id == 1001) {
  69.          return (super.eventMask & 128L) != 0L || this.actionListener != null;
  70.       } else {
  71.          return super.eventEnabled(var1);
  72.       }
  73.    }
  74.  
  75.    protected void processEvent(AWTEvent var1) {
  76.       if (var1 instanceof ActionEvent) {
  77.          this.processActionEvent((ActionEvent)var1);
  78.       } else {
  79.          super.processEvent(var1);
  80.       }
  81.    }
  82.  
  83.    protected void processActionEvent(ActionEvent var1) {
  84.       if (this.actionListener != null) {
  85.          this.actionListener.actionPerformed(var1);
  86.       }
  87.  
  88.    }
  89.  
  90.    protected String paramString() {
  91.       return super.paramString() + ",label=" + this.label;
  92.    }
  93.  
  94.    private void writeObject(ObjectOutputStream var1) throws IOException {
  95.       var1.defaultWriteObject();
  96.       AWTEventMulticaster.save(var1, "actionL", this.actionListener);
  97.       var1.writeObject((Object)null);
  98.    }
  99.  
  100.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  101.       var1.defaultReadObject();
  102.  
  103.       Object var2;
  104.       while((var2 = var1.readObject()) != null) {
  105.          String var3 = ((String)var2).intern();
  106.          if (var3 == "actionL") {
  107.             this.addActionListener((ActionListener)var1.readObject());
  108.          } else {
  109.             var1.readObject();
  110.          }
  111.       }
  112.  
  113.    }
  114. }
  115.