home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 31 / SUPERCDa.iso / Inet / HotJava / hjava.exe / Windows / resource / jre / lib / rt.jar / java / awt / Button.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-11  |  3.4 KB  |  126 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.       this.label = var1;
  26.    }
  27.  
  28.    String constructComponentName() {
  29.       return "button" + nameCounter++;
  30.    }
  31.  
  32.    public void addNotify() {
  33.       Object var1 = ((Component)this).getTreeLock();
  34.       synchronized(var1){}
  35.  
  36.       try {
  37.          if (super.peer == null) {
  38.             super.peer = ((Component)this).getToolkit().createButton(this);
  39.          }
  40.  
  41.          super.addNotify();
  42.       } catch (Throwable var3) {
  43.          throw var3;
  44.       }
  45.  
  46.    }
  47.  
  48.    public String getLabel() {
  49.       return this.label;
  50.    }
  51.  
  52.    public synchronized void setLabel(String var1) {
  53.       this.label = var1;
  54.       ButtonPeer var2 = (ButtonPeer)super.peer;
  55.       if (var2 != null) {
  56.          var2.setLabel(var1);
  57.       }
  58.  
  59.    }
  60.  
  61.    public void setActionCommand(String var1) {
  62.       this.actionCommand = var1;
  63.    }
  64.  
  65.    public String getActionCommand() {
  66.       return this.actionCommand == null ? this.label : this.actionCommand;
  67.    }
  68.  
  69.    public synchronized void addActionListener(ActionListener var1) {
  70.       this.actionListener = AWTEventMulticaster.add(this.actionListener, var1);
  71.       super.newEventsOnly = true;
  72.    }
  73.  
  74.    public synchronized void removeActionListener(ActionListener var1) {
  75.       this.actionListener = AWTEventMulticaster.remove(this.actionListener, var1);
  76.    }
  77.  
  78.    boolean eventEnabled(AWTEvent var1) {
  79.       if (var1.id == 1001) {
  80.          return (super.eventMask & 128L) != 0L || this.actionListener != null;
  81.       } else {
  82.          return super.eventEnabled(var1);
  83.       }
  84.    }
  85.  
  86.    protected void processEvent(AWTEvent var1) {
  87.       if (var1 instanceof ActionEvent) {
  88.          this.processActionEvent((ActionEvent)var1);
  89.       } else {
  90.          super.processEvent(var1);
  91.       }
  92.    }
  93.  
  94.    protected void processActionEvent(ActionEvent var1) {
  95.       if (this.actionListener != null) {
  96.          this.actionListener.actionPerformed(var1);
  97.       }
  98.  
  99.    }
  100.  
  101.    protected String paramString() {
  102.       return super.paramString() + ",label=" + this.label;
  103.    }
  104.  
  105.    private void writeObject(ObjectOutputStream var1) throws IOException {
  106.       var1.defaultWriteObject();
  107.       AWTEventMulticaster.save(var1, "actionL", this.actionListener);
  108.       var1.writeObject((Object)null);
  109.    }
  110.  
  111.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  112.       var1.defaultReadObject();
  113.  
  114.       Object var2;
  115.       while((var2 = var1.readObject()) != null) {
  116.          String var3 = ((String)var2).intern();
  117.          if (var3 == "actionL") {
  118.             this.addActionListener((ActionListener)var1.readObject());
  119.          } else {
  120.             var1.readObject();
  121.          }
  122.       }
  123.  
  124.    }
  125. }
  126.