本文整理匯總了Java中java.awt.CheckboxGroup類的典型用法代碼示例。如果您正苦於以下問題:Java CheckboxGroup類的具體用法?Java CheckboxGroup怎麽用?Java CheckboxGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CheckboxGroup類屬於java.awt包,在下文中一共展示了CheckboxGroup類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: itemStateChanged
import java.awt.CheckboxGroup; //導入依賴的package包/類
@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()));
}
}
});
}
示例2: setCheckboxGroup
import java.awt.CheckboxGroup; //導入依賴的package包/類
@Override
public void setCheckboxGroup(final CheckboxGroup g) {
synchronized (getDelegateLock()) {
getDelegate().getCurrentButton().removeItemListener(this);
getDelegate().setRadioButton(g != null);
getDelegate().getCurrentButton().addItemListener(this);
}
repaintPeer();
}
示例3: getCheckboxGroup
import java.awt.CheckboxGroup; //導入依賴的package包/類
/**
* Maps {@code Checkbox.getCheckboxGroup()} through queue
*/
public CheckboxGroup getCheckboxGroup() {
return (runMapping(new MapAction<CheckboxGroup>("getCheckboxGroup") {
@Override
public CheckboxGroup map() {
return ((Checkbox) getSource()).getCheckboxGroup();
}
}));
}
示例4: setCheckboxGroup
import java.awt.CheckboxGroup; //導入依賴的package包/類
/**
* 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);
}
});
}
示例5: DrawControls
import java.awt.CheckboxGroup; //導入依賴的package包/類
@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);
}
示例6: setCheckboxGroup
import java.awt.CheckboxGroup; //導入依賴的package包/類
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;
}
示例7: setCheckboxGroup
import java.awt.CheckboxGroup; //導入依賴的package包/類
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;
}