List of usage examples for javax.swing JButton addItemListener
public void addItemListener(ItemListener l)
ItemListener
to the checkbox
. From source file:MainClass.java
public static void main(String[] args) { JButton jb = new JButton("Press Me"); jb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { System.out.println("ItemEvent!"); }/*from w w w .j a va 2 s .c o m*/ }); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); } }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }