home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / awt / Button.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  4.2 KB  |  175 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. import java.util.EventListener;
  10. import javax.accessibility.Accessible;
  11. import javax.accessibility.AccessibleContext;
  12.  
  13. public class Button extends Component implements Accessible {
  14.    String label;
  15.    String actionCommand;
  16.    transient ActionListener actionListener;
  17.    private static final String base = "button";
  18.    private static int nameCounter = 0;
  19.    private static final long serialVersionUID = -8774683716313001058L;
  20.    private int buttonSerializedDataVersion;
  21.  
  22.    private static native void initIDs();
  23.  
  24.    public Button() throws HeadlessException {
  25.       this("");
  26.    }
  27.  
  28.    public Button(String var1) throws HeadlessException {
  29.       this.buttonSerializedDataVersion = 1;
  30.       GraphicsEnvironment.checkHeadless();
  31.       this.label = var1;
  32.    }
  33.  
  34.    String constructComponentName() {
  35.       synchronized(this.getClass()) {
  36.          return "button" + nameCounter++;
  37.       }
  38.    }
  39.  
  40.    public void addNotify() {
  41.       synchronized(this.getTreeLock()) {
  42.          if (this.peer == null) {
  43.             this.peer = this.getToolkit().createButton(this);
  44.          }
  45.  
  46.          super.addNotify();
  47.       }
  48.    }
  49.  
  50.    public String getLabel() {
  51.       return this.label;
  52.    }
  53.  
  54.    public void setLabel(String var1) {
  55.       boolean var2 = false;
  56.       synchronized(this) {
  57.          if (var1 != this.label && (this.label == null || !this.label.equals(var1))) {
  58.             this.label = var1;
  59.             ButtonPeer var4 = (ButtonPeer)this.peer;
  60.             if (var4 != null) {
  61.                var4.setLabel(var1);
  62.             }
  63.  
  64.             var2 = true;
  65.          }
  66.       }
  67.  
  68.       if (var2 && this.valid) {
  69.          this.invalidate();
  70.       }
  71.  
  72.    }
  73.  
  74.    public void setActionCommand(String var1) {
  75.       this.actionCommand = var1;
  76.    }
  77.  
  78.    public String getActionCommand() {
  79.       return this.actionCommand == null ? this.label : this.actionCommand;
  80.    }
  81.  
  82.    public synchronized void addActionListener(ActionListener var1) {
  83.       if (var1 != null) {
  84.          this.actionListener = AWTEventMulticaster.add(this.actionListener, var1);
  85.          this.newEventsOnly = true;
  86.       }
  87.    }
  88.  
  89.    public synchronized void removeActionListener(ActionListener var1) {
  90.       if (var1 != null) {
  91.          this.actionListener = AWTEventMulticaster.remove(this.actionListener, var1);
  92.       }
  93.    }
  94.  
  95.    public synchronized ActionListener[] getActionListeners() {
  96.       return (ActionListener[])this.getListeners(ActionListener.class);
  97.    }
  98.  
  99.    public <T extends EventListener> T[] getListeners(Class<T> var1) {
  100.       Object var2 = null;
  101.       if (var1 == ActionListener.class) {
  102.          ActionListener var3 = this.actionListener;
  103.          return (T[])AWTEventMulticaster.getListeners(var3, var1);
  104.       } else {
  105.          return (T[])super.getListeners(var1);
  106.       }
  107.    }
  108.  
  109.    boolean eventEnabled(AWTEvent var1) {
  110.       if (var1.id == 1001) {
  111.          return (this.eventMask & 128L) != 0L || this.actionListener != null;
  112.       } else {
  113.          return super.eventEnabled(var1);
  114.       }
  115.    }
  116.  
  117.    protected void processEvent(AWTEvent var1) {
  118.       if (var1 instanceof ActionEvent) {
  119.          this.processActionEvent((ActionEvent)var1);
  120.       } else {
  121.          super.processEvent(var1);
  122.       }
  123.    }
  124.  
  125.    protected void processActionEvent(ActionEvent var1) {
  126.       ActionListener var2 = this.actionListener;
  127.       if (var2 != null) {
  128.          var2.actionPerformed(var1);
  129.       }
  130.  
  131.    }
  132.  
  133.    protected String paramString() {
  134.       return super.paramString() + ",label=" + this.label;
  135.    }
  136.  
  137.    private void writeObject(ObjectOutputStream var1) throws IOException {
  138.       var1.defaultWriteObject();
  139.       AWTEventMulticaster.save(var1, "actionL", this.actionListener);
  140.       var1.writeObject((Object)null);
  141.    }
  142.  
  143.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException, HeadlessException {
  144.       GraphicsEnvironment.checkHeadless();
  145.       var1.defaultReadObject();
  146.  
  147.       Object var2;
  148.       while(null != (var2 = var1.readObject())) {
  149.          String var3 = ((String)var2).intern();
  150.          if ("actionL" == var3) {
  151.             this.addActionListener((ActionListener)var1.readObject());
  152.          } else {
  153.             var1.readObject();
  154.          }
  155.       }
  156.  
  157.    }
  158.  
  159.    public AccessibleContext getAccessibleContext() {
  160.       if (this.accessibleContext == null) {
  161.          this.accessibleContext = new AccessibleAWTButton(this);
  162.       }
  163.  
  164.       return this.accessibleContext;
  165.    }
  166.  
  167.    static {
  168.       Toolkit.loadLibraries();
  169.       if (!GraphicsEnvironment.isHeadless()) {
  170.          initIDs();
  171.       }
  172.  
  173.    }
  174. }
  175.