當前位置: 首頁>>代碼示例>>Java>>正文


Java CheckboxGroup類代碼示例

本文整理匯總了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()));
            }
        }
    });
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:LWCheckboxPeer.java

示例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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:LWCheckboxPeer.java

示例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();
        }
    }));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:CheckboxOperator.java

示例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);
        }
    });
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:CheckboxOperator.java

示例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);
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:35,代碼來源:DrawTest.java

示例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;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:16,代碼來源:QtCheckboxPeer.java

示例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;
 }
 
開發者ID:nmldiegues,項目名稱:jvm-stm,代碼行數:16,代碼來源:QtCheckboxPeer.java


注:本文中的java.awt.CheckboxGroup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。