📜  java 切换按钮获取状态 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:25.684000             🧑  作者: Mango

代码示例1
JToggleButton jtb = new JToggleButton("Press Me");
jtb.addItemListener(new ItemListener() {
   public void itemStateChanged(ItemEvent ev) {
      if(ev.getStateChange()==ItemEvent.SELECTED){
        System.out.println("button is selected");
      } else if(ev.getStateChange()==ItemEvent.DESELECTED){
        System.out.println("button is not selected");
      }
   }
});