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

  1. package sun.awt.macos;
  2.  
  3. import java.awt.Checkbox;
  4. import java.awt.CheckboxGroup;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.FontMetrics;
  9. import java.awt.event.ItemEvent;
  10. import java.awt.peer.CheckboxPeer;
  11.  
  12. public class MCheckboxPeer extends MComponentPeer implements CheckboxPeer {
  13.    boolean isRadioButton;
  14.  
  15.    public MCheckboxPeer(Checkbox var1) {
  16.       super(var1);
  17.    }
  18.  
  19.    native void create(MComponentPeer var1);
  20.  
  21.    void initialize() {
  22.       super.initialize();
  23.       this.isRadioButton = false;
  24.    }
  25.  
  26.    public Dimension minimumSize() {
  27.       String var1 = ((Checkbox)super.target).getLabel();
  28.       if (var1 != null) {
  29.          FontMetrics var2 = ((MComponentPeer)this).getFontMetrics(super.target.getFont());
  30.          return new Dimension(30 + var2.stringWidth(var1), Math.max(var2.getHeight() + 8, 16));
  31.       } else {
  32.          return new Dimension(20, 16);
  33.       }
  34.    }
  35.  
  36.    public native void setLabel(String var1);
  37.  
  38.    public native void setState(boolean var1);
  39.  
  40.    public void setCheckboxGroup(CheckboxGroup var1) {
  41.       if (var1 == null && this.isRadioButton || var1 != null && !this.isRadioButton) {
  42.          ((MComponentPeer)this).dispose();
  43.          Container var2 = super.target.getParent();
  44.          ((MComponentPeer)this).setup();
  45.          this.create((MComponentPeer)(var2 != null ? ((Component)var2).getPeer() : null));
  46.       }
  47.  
  48.    }
  49.  
  50.    public void handleAction(boolean var1) {
  51.       Checkbox var2 = (Checkbox)super.target;
  52.       var2.setState(var1);
  53.       MToolkit.postEvent(new ItemEvent(var2, 701, var2.getLabel(), var1 ? 1 : 2));
  54.    }
  55.  
  56.    public boolean isFocusTraversable() {
  57.       return true;
  58.    }
  59. }
  60.