List of usage examples for javax.swing JRadioButtonMenuItem setAction
@BeanProperty(visualUpdate = true, description = "the Action instance connected with this ActionEvent source") public void setAction(Action a)
Action
. From source file:ffx.ui.MainMenu.java
private JRadioButtonMenuItem addBGMI(ButtonGroup buttonGroup, JMenu menu, String icon, String actionCommand, int mnemonic, int accelerator, final ActionListener actionListener) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(); Action a = new AbstractAction() { @Override/*from w w w .j a va 2 s .c o m*/ public void actionPerformed(ActionEvent e) { /** * If the ActionEvent is from a ToolBar button, pass it through * the JRadioButtonMenuItem. */ if (e.getSource() != menuItem) { menuItem.doClick(); return; } actionListener.actionPerformed(e); } }; this.configureAction(a, icon, actionCommand, mnemonic, accelerator); menuItem.setAction(a); buttonGroup.add(menuItem); menu.add(menuItem); return menuItem; }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
public JMenu getViewMenu() { if (viewMenu == null) { viewMenu = new JMenu(viewMenuLabelText); ButtonGroup viewButtonGroup = new ButtonGroup(); for (int i = 0; i < VIEWTYPE_COUNT; i++) { JRadioButtonMenuItem mi = new JRadioButtonMenuItem(); mi.setAction(new ViewTypeAction(i)); viewButtonGroup.add(mi);//from w w w. j a v a 2 s . c o m viewMenu.add(mi); } updateViewMenu(); } return viewMenu; }