java.awt.CheckboxMenuItem Java Examples

The following examples show how to use java.awt.CheckboxMenuItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckboxMenuItemGroup.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
  CheckboxMenuItem checkedItem = ((CheckboxMenuItem) e.getSource());
  if (e.getStateChange() == ItemEvent.SELECTED) {
    String selectedItemName = checkedItem.getName();
    for (CheckboxMenuItem item : items) {
      if (!item.getName().equals(selectedItemName)) {
        item.setState(false);
      }
    }
    if (itemListener != null) {
      itemListener.itemStateChanged(e);
    }
  } else {
    checkedItem.setState(true);
  }
}
 
Example #2
Source File: CheckboxMenuItemGroup.java    From proxyee-down with Apache License 2.0 6 votes vote down vote up
@Override
public void itemStateChanged(ItemEvent e) {
  CheckboxMenuItem checkedItem = ((CheckboxMenuItem) e.getSource());
  if (e.getStateChange() == ItemEvent.SELECTED) {
    String selectedItemName = checkedItem.getName();
    for (CheckboxMenuItem item : items) {
      if (!item.getName().equals(selectedItemName)) {
        item.setState(false);
      }
    }
    if (itemListener != null) {
      itemListener.itemStateChanged(e);
    }
  } else {
    checkedItem.setState(true);
  }
}
 
Example #3
Source File: WCheckboxMenuItemPeer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #4
Source File: CheckboxMenuItemGroup.java    From proxyee-down with Apache License 2.0 5 votes vote down vote up
public CheckboxMenuItem getSelectedItem() {
  for (CheckboxMenuItem item : items) {
    if (item.getState()) {
      return item;
    }
  }
  return null;
}
 
Example #5
Source File: CCheckboxMenuItem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #6
Source File: CCheckboxMenuItem.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #7
Source File: WCheckboxMenuItemPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #8
Source File: CCheckboxMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #9
Source File: WCheckboxMenuItemPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #10
Source File: CCheckboxMenuItem.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #11
Source File: WCheckboxMenuItemPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #12
Source File: CCheckboxMenuItem.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #13
Source File: CCheckboxMenuItem.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #14
Source File: CCheckboxMenuItem.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #15
Source File: WCheckboxMenuItemPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #16
Source File: CCheckboxMenuItem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #17
Source File: WCheckboxMenuItemPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #18
Source File: CCheckboxMenuItem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #19
Source File: WCheckboxMenuItemPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #20
Source File: CheckboxMenuItemGroup.java    From proxyee-down with Apache License 2.0 5 votes vote down vote up
public CheckboxMenuItem getSelectedItem() {
  for (CheckboxMenuItem item : items) {
    if (item.getState()) {
      return item;
    }
  }
  return null;
}
 
Example #21
Source File: CCheckboxMenuItem.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #22
Source File: WCheckboxMenuItemPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #23
Source File: WCheckboxMenuItemPeer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #24
Source File: WCheckboxMenuItemPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #25
Source File: CCheckboxMenuItem.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #26
Source File: WCheckboxMenuItemPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
    WToolkit.executeOnEventHandlerThread(target, new Runnable() {
        @Override
        public void run() {
            target.setState(state);
            postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
                                    target.getLabel(), (state)
                                      ? ItemEvent.SELECTED
                                      : ItemEvent.DESELECTED));
        }
    });
}
 
Example #27
Source File: CCheckboxMenuItem.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #28
Source File: CCheckboxMenuItem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void handleAction(final boolean state) {
    final CheckboxMenuItem target = (CheckboxMenuItem)getTarget();
    SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
        public void run() {
            target.setState(state);
        }
    });
    ItemEvent event = new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED, target.getLabel(), state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
    SunToolkit.postEvent(SunToolkit.targetToAppContext(getTarget()), event);
}
 
Example #29
Source File: WCheckboxMenuItemPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
WCheckboxMenuItemPeer(CheckboxMenuItem target) {
    super(target, true);
    setState(target.getState());
}
 
Example #30
Source File: CCheckboxMenuItem.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
CCheckboxMenuItem(final CheckboxMenuItem target) {
    super(target);
    execute(this::nativeSetIsCheckbox);
    setState(target.getState());
}