本文整理了Java中javax.swing.JCheckBox.getListeners()
方法的一些代码示例,展示了JCheckBox.getListeners()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JCheckBox.getListeners()
方法的具体详情如下:
包路径:javax.swing.JCheckBox
类名称:JCheckBox
方法名:getListeners
暂无
代码示例来源:origin: stackoverflow.com
JCheckBox checkBox = new JCheckBox("Check Box");
EventListener[] listeners = checkBox.getListeners(MouseListener.class);
for (EventListener eventListener : listeners) {
checkBox.removeMouseListener((MouseListener) eventListener);
}
代码示例来源:origin: stackoverflow.com
public static void main(String [] args)
{
JCheckBox checkBox = new JCheckBox();
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent arg0) {
// TODO Auto-generated method stub
}
});
ItemListener [] itemListeners = checkBox.getListeners(ItemListener.class);
System.out.println(itemListeners.length);
for (int i = 0; i < itemListeners.length; i++)
{
checkBox.removeItemListener(itemListeners[i]);
}
System.out.println(checkBox.getListeners(ItemListener.class).length);
}
代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij
/**
* Checks or unchecks the given checkbox. {@link ActionListener} does not respond to {@link
* JCheckBox#setSelected(boolean)} so the attached listeners are manually invoked.
*
* @param checkbox the checkbox to check or uncheck
* @param select whether to check or uncheck it
*/
private static void checkEnableCheckbox(JCheckBox checkbox, boolean select) {
checkbox.setSelected(select);
ActionEvent e = new ActionEvent(checkbox, 1, "");
Arrays.stream(checkbox.getListeners(ActionListener.class))
.forEach(listener -> listener.actionPerformed(e));
}
内容来源于网络,如有侵权,请联系作者删除!