home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.macos;
-
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.FontMetrics;
- import java.awt.event.ItemEvent;
- import java.awt.peer.CheckboxPeer;
-
- public class MCheckboxPeer extends MComponentPeer implements CheckboxPeer {
- boolean isRadioButton;
-
- public MCheckboxPeer(Checkbox var1) {
- super(var1);
- }
-
- native void create(MComponentPeer var1);
-
- void initialize() {
- super.initialize();
- this.isRadioButton = false;
- }
-
- public Dimension minimumSize() {
- String var1 = ((Checkbox)super.target).getLabel();
- if (var1 != null) {
- FontMetrics var2 = ((MComponentPeer)this).getFontMetrics(super.target.getFont());
- return new Dimension(30 + var2.stringWidth(var1), Math.max(var2.getHeight() + 8, 16));
- } else {
- return new Dimension(20, 16);
- }
- }
-
- public native void setLabel(String var1);
-
- public native void setState(boolean var1);
-
- public void setCheckboxGroup(CheckboxGroup var1) {
- if (var1 == null && this.isRadioButton || var1 != null && !this.isRadioButton) {
- ((MComponentPeer)this).dispose();
- Container var2 = super.target.getParent();
- ((MComponentPeer)this).setup();
- this.create((MComponentPeer)(var2 != null ? ((Component)var2).getPeer() : null));
- }
-
- }
-
- public void handleAction(boolean var1) {
- Checkbox var2 = (Checkbox)super.target;
- var2.setState(var1);
- MToolkit.postEvent(new ItemEvent(var2, 701, var2.getLabel(), var1 ? 1 : 2));
- }
-
- public boolean isFocusTraversable() {
- return true;
- }
- }
-