Java 类java.awt.CheckboxGroup 实例源码

项目:OpenJSharp    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:OpenJSharp    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:OpenJSharp    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:jdk8u-jdk    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:jdk8u-jdk    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:jdk8u-jdk    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:openjdk-jdk10    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:openjdk-jdk10    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:openjdk-jdk10    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:openjdk-jdk10    文件:CheckboxOperator.java   
/**
 * Maps {@code Checkbox.getCheckboxGroup()} through queue
 */
public CheckboxGroup getCheckboxGroup() {
    return (runMapping(new MapAction<CheckboxGroup>("getCheckboxGroup") {
        @Override
        public CheckboxGroup map() {
            return ((Checkbox) getSource()).getCheckboxGroup();
        }
    }));
}
项目:openjdk-jdk10    文件:CheckboxOperator.java   
/**
 * Maps {@code Checkbox.setCheckboxGroup(CheckboxGroup)} through queue
 */
public void setCheckboxGroup(final CheckboxGroup grp) {
    runMapping(new MapVoidAction("setCheckboxGroup") {
        @Override
        public void map() {
            ((Checkbox) getSource()).setCheckboxGroup(grp);
        }
    });
}
项目:openjdk9    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:openjdk9    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:openjdk9    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:openjdk9    文件:CheckboxOperator.java   
/**
 * Maps {@code Checkbox.getCheckboxGroup()} through queue
 */
public CheckboxGroup getCheckboxGroup() {
    return (runMapping(new MapAction<CheckboxGroup>("getCheckboxGroup") {
        @Override
        public CheckboxGroup map() {
            return ((Checkbox) getSource()).getCheckboxGroup();
        }
    }));
}
项目:openjdk9    文件:CheckboxOperator.java   
/**
 * Maps {@code Checkbox.setCheckboxGroup(CheckboxGroup)} through queue
 */
public void setCheckboxGroup(final CheckboxGroup grp) {
    runMapping(new MapVoidAction("setCheckboxGroup") {
        @Override
        public void map() {
            ((Checkbox) getSource()).setCheckboxGroup(grp);
        }
    });
}
项目:jdk8u_jdk    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:jdk8u_jdk    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:jdk8u_jdk    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:lookaside_java-1.8.0-openjdk    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:lookaside_java-1.8.0-openjdk    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:javify    文件:QtCheckboxPeer.java   
public void setCheckboxGroup( CheckboxGroup group )
{
  if(this.group == group)
    return;

  // if we change from a checkbox to a radio button or vice versa
  if((this.group == null) != (group == null))
    {
      this.group = group;
      callInit();
      setup();
    }

  this.group = group;
}
项目:jvm-stm    文件:QtCheckboxPeer.java   
public void setCheckboxGroup( CheckboxGroup group )
 {    
   if(this.group == group) 
     return;

   // if we change from a checkbox to a radio button or vice versa
   if((this.group == null) != (group == null))
     {
this.group = group;
callInit();
setup();
     }

   this.group = group;
 }
项目:Advanced-Trigoplex    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:infobip-open-jdk-8    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:infobip-open-jdk-8    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:infobip-open-jdk-8    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:jdk8u-dev-jdk    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:jdk8u-dev-jdk    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:jdk8u-dev-jdk    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:jdk7-jdk    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:openjdk-source-code-learn    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:OLD-OpenJDK8    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:OLD-OpenJDK8    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:OLD-OpenJDK8    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}
项目:JamVM-PH    文件:QtCheckboxPeer.java   
public void setCheckboxGroup( CheckboxGroup group )
 {    
   if(this.group == group) 
     return;

   // if we change from a checkbox to a radio button or vice versa
   if((this.group == null) != (group == null))
     {
this.group = group;
callInit();
setup();
     }

   this.group = group;
 }
项目:openjdk-jdk7u-jdk    文件:DrawTest.java   
@SuppressWarnings("LeakingThisInConstructor")
public DrawControls(DrawPanel target) {
    this.target = target;
    setLayout(new FlowLayout());
    setBackground(Color.lightGray);
    target.setForeground(Color.red);
    CheckboxGroup group = new CheckboxGroup();
    Checkbox b;
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.red);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.green);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.blue);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.pink);
    add(b = new Checkbox(null, group, false));
    b.addItemListener(this);
    b.setForeground(Color.orange);
    add(b = new Checkbox(null, group, true));
    b.addItemListener(this);
    b.setForeground(Color.black);
    target.setForeground(b.getForeground());
    Choice shapes = new Choice();
    shapes.addItemListener(this);
    shapes.addItem("Lines");
    shapes.addItem("Points");
    shapes.setBackground(Color.lightGray);
    add(shapes);
}
项目:openjdk-jdk7u-jdk    文件:LWCheckboxPeer.java   
@Override
public void itemStateChanged(final ItemEvent e) {
    // group.setSelectedCheckbox() will repaint the component
    // to let LWCheckboxPeer correctly handle it we should call it
    // after the current event is processed
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            boolean postEvent = true;
            final CheckboxGroup group = getTarget().getCheckboxGroup();
            if (group != null) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    if (group.getSelectedCheckbox() != getTarget()) {
                        group.setSelectedCheckbox(getTarget());
                    } else {
                        postEvent = false;
                    }
                } else {
                    postEvent = false;
                    if (group.getSelectedCheckbox() == getTarget()) {
                        // Don't want to leave the group with no selected
                        // checkbox.
                        getTarget().setState(true);
                    }
                }
            } else {
                getTarget().setState(e.getStateChange()
                                     == ItemEvent.SELECTED);
            }
            if (postEvent) {
                postEvent(new ItemEvent(getTarget(),
                                        ItemEvent.ITEM_STATE_CHANGED,
                                        getTarget().getLabel(),
                                        e.getStateChange()));
            }
        }
    });
}
项目:openjdk-jdk7u-jdk    文件:LWCheckboxPeer.java   
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
    synchronized (getDelegateLock()) {
        getDelegate().getCurrentButton().removeItemListener(this);
        getDelegate().setRadioButton(g != null);
        getDelegate().getCurrentButton().addItemListener(this);
    }
    repaintPeer();
}