public MyToolBar(final Hashtable<Integer, Action> actions) { super(); add(new JButton(actions.get(SharedActions.ACTION1_KEY))); add(new JButton(actions.get(SharedActions.ACTION2_KEY))); JToggleButton btn = new JToggleButton(actions.get(SharedActions.ACTION3_KEY)); SharedActions.registerToggleAction(btn, SharedActions.ACTION3_KEY); add(btn); btn = new JToggleButton(actions.get(SharedActions.ACTION4_KEY)); SharedActions.registerToggleAction(btn, SharedActions.ACTION4_KEY); add(btn); }
/** Build our JPopupMenu */ public void buildPopupMenu() { this.popup.add(new JMenuItem(actionTable.get(SharedActions.ACTION1_KEY))); this.popup.add(new JMenuItem(actionTable.get(SharedActions.ACTION2_KEY))); JCheckBoxMenuItem item = new JCheckBoxMenuItem(actionTable.get(SharedActions.ACTION3_KEY)); SharedActions.registerToggleAction(item, SharedActions.ACTION3_KEY); this.popup.add(item); item = new JCheckBoxMenuItem(actionTable.get(SharedActions.ACTION4_KEY)); SharedActions.registerToggleAction(item, SharedActions.ACTION4_KEY); this.popup.add(item); this.popup.add(new JSeparator()); this.popup.add(new JMenuItem(actionTable.get(SharedActions.EXIT_KEY))); }
public MyMenuBar(final Hashtable<Integer, Action> actions) { JMenu menu = new JMenu("File"); menu.setMnemonic('F'); menu.add(new JMenuItem(actions.get(SharedActions.ACTION1_KEY))); menu.add(new JMenuItem(actions.get(SharedActions.ACTION2_KEY))); menu.add(new JSeparator()); JCheckBoxMenuItem item = new JCheckBoxMenuItem(actions.get(SharedActions.ACTION3_KEY)); SharedActions.registerToggleAction(item, SharedActions.ACTION3_KEY); menu.add(item); item = new JCheckBoxMenuItem(actions.get(SharedActions.ACTION4_KEY)); SharedActions.registerToggleAction(item, SharedActions.ACTION4_KEY); menu.add(item); menu.add(new JMenuItem(actions.get(SharedActions.EXIT_KEY))); add(menu); menu = new JMenu("Help"); menu.setMnemonic('H'); menu.add(new JMenuItem((Action) actions.get(SharedActions.ABOUT_KEY))); add(menu); }