List of usage examples for javax.swing AbstractButton addItemListener
public void addItemListener(ItemListener l)
ItemListener
to the checkbox
. From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { System.out.println("ItemEvent!"); }/* ww w.ja v a2s. c o m*/ }); ItemListener[] lis = jb.getItemListeners(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { System.out.println("ItemEvent!"); }//from w ww. j a v a2 s . c om }); 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); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.GlobalViewConditionController.java
/** * Initialize plot settings menu bar// w w w . j a va 2 s .c o m */ private void initPlotSettingsMenuBar() { // create new object plotSettingsMenuBar = new PlotSettingsMenuBar(); /** * Add item listeners to the menu items */ ItemActionListener itemActionListener = new ItemActionListener(); plotSettingsMenuBar.getPlotLinesCheckBoxMenuItem().addItemListener(itemActionListener); plotSettingsMenuBar.getPlotPointsCheckBoxMenuItem().addItemListener(itemActionListener); plotSettingsMenuBar.getShowEndPointsCheckBoxMenuItem().addItemListener(itemActionListener); for (Enumeration<AbstractButton> buttons = plotSettingsMenuBar.getLinesButtonGroup().getElements(); buttons .hasMoreElements();) { AbstractButton button = buttons.nextElement(); button.addItemListener(itemActionListener); } plotSettingsMenuBar.getUseCellMissyColors().addItemListener(new ColorItemActionListener()); }