List of usage examples for javax.swing JMenu add
public JMenuItem add(Action a)
From source file:com.haskins.cloudtrailviewer.sidebar.EventsChart.java
private JMenu getSessionContextMenu(ButtonGroup buttonGroup) { JMenu sessionContext = new JMenu("Session Context"); sessionContext.add(getSessionIssuerMenu(buttonGroup)); return sessionContext; }
From source file:ucar.unidata.idv.flythrough.ChartDecorator.java
public void initViewMenu(JMenu viewMenu) { viewMenu.add(GuiUtils.makeCheckboxMenuItem("Collect data", this, "collectSamples", null)); super.initViewMenu(viewMenu); }
From source file:org.simbrain.plot.barchart.BarChartGui.java
/** * Creates the menu bar./*from w w w .ja v a2 s.com*/ */ private void createAttachMenuBar() { JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); for (Action action : actionManager.getOpenSavePlotActions()) { fileMenu.add(action); } fileMenu.addSeparator(); fileMenu.add(new CloseAction(this.getWorkspaceComponent())); JMenu editMenu = new JMenu("Edit"); JMenuItem preferences = new JMenuItem("Preferences..."); preferences.addActionListener(this); preferences.setActionCommand("dialog"); editMenu.add(preferences); JMenu helpMenu = new JMenu("Help"); ShowHelpAction helpAction = new ShowHelpAction("Pages/Plot/bar_chart.html"); JMenuItem helpItem = new JMenuItem(helpAction); helpMenu.add(helpItem); bar.add(fileMenu); bar.add(editMenu); bar.add(helpMenu); getParentFrame().setJMenuBar(bar); }
From source file:EditorPaneExample20.java
public static JMenu buildMenu(String name, MenuSpec[] menuSpecs, Hashtable actions) { int count = menuSpecs.length; JMenu menu = new JMenu(name); for (int i = 0; i < count; i++) { MenuSpec spec = menuSpecs[i];//www . j a v a2s. co m if (spec.isSubMenu()) { // Recurse to handle a sub menu JMenu subMenu = buildMenu(spec.getName(), spec.getSubMenus(), actions); if (subMenu != null) { menu.add(subMenu); } } else if (spec.isAction()) { // It's an Action - add it directly to the menu menu.add(spec.getAction()); } else { // It's an action name - add it if possible String actionName = spec.getActionName(); Action targetAction = (Action) actions.get(actionName); // Create the menu item JMenuItem menuItem = menu.add(spec.getName()); if (targetAction != null) { // The editor kit knows the action menuItem.addActionListener(targetAction); } else { // Action not known - disable the menu item menuItem.setEnabled(false); } } } // Return null if nothing was added to the menu. if (menu.getMenuComponentCount() == 0) { menu = null; } return menu; }
From source file:de.genvlin.plugins.jfreechart.JFreeChartPluginImpl.java
public void sendRequest(RequestEvent ri) { if (ri.getActionContextReason() == PluginPool.SELECTED_COLS) { selected = (VectorInterface[]) ((GTablePanel) ri.getSource()).getSelectedVectors(); JMenu menu = new JMenu(getName()); JMenuItem item = new JMenuItem(getMenuName()); item.setActionCommand(getMenuName()); menu.add(item); item.addActionListener(this); item = new JMenuItem(LINEAR_REG); item.setActionCommand(LINEAR_REG); menu.add(item);/*ww w. j a va 2 s . c o m*/ item.addActionListener(this); ((JPopupMenu) ri.getObject()).add(menu); } }
From source file:Main.java
public Main() { super("Browser"); setDefaultCloseOperation(EXIT_ON_CLOSE); JMenuBar mb = new JMenuBar(); JMenu mFile = new JMenu("File"); JMenuItem mi = new JMenuItem("Add Tab"); ActionListener addTabl = new ActionListener() { public void actionPerformed(ActionEvent e) { addTab();/*from www . j ava 2s. co m*/ } }; mi.addActionListener(addTabl); mFile.add(mi); mb.add(mFile); setJMenuBar(mb); JPanel pnlURL = new JPanel(); tp = new JTabbedPane(); addTab(); add(tp, BorderLayout.CENTER); setSize(300, 300); setVisible(true); }
From source file:cz.lidinsky.editor.Menu.java
protected JMenuItem loadMenuItem(Properties settings, String key) { try {//from www . j av a 2 s . com String temp = settings.getProperty(key + "_menu_items"); JMenuItem menuItem; if (temp != null) { JMenu menu = new JMenu(); String menuItems[] = temp.split(" "); for (String item : menuItems) { if (item.equals("|")) { menu.add(new JSeparator()); } else { menu.add(loadMenuItem(settings, item)); } } menuItem = menu; } else { menuItem = new JMenuItem(); } // set the menu item label setLabel(menuItem, settings.getProperty(key + "_menu_label")); // action String actionKey = settings.getProperty(key + "_menu_action"); if (actionKey != null) { menuItem.setAction(Action.getAction(settings, actionKey)); } return menuItem; } catch (Exception e) { // TODO: throw new AssertionError(); } }
From source file:MainClass.java
public MainClass() { JFrame frame = new JFrame(); textPane = new JTextPane(); JScrollPane scrollPane = new JScrollPane(textPane); JPanel north = new JPanel(); JButton print = new JButton("Print"); print.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { paintToPDF(textPane);/*from w w w . ja v a 2 s. co m*/ } }); JMenuBar menu = new JMenuBar(); JMenu styleMenu = new JMenu(); styleMenu.setText("Style"); Action boldAction = new BoldAction(); boldAction.putValue(Action.NAME, "Bold"); styleMenu.add(boldAction); Action italicAction = new ItalicAction(); italicAction.putValue(Action.NAME, "Italic"); styleMenu.add(italicAction); menu.add(styleMenu); north.add(menu); north.add(print); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(north, BorderLayout.NORTH); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(800, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:com.haskins.cloudtrailviewer.sidebar.EventsChart.java
private JMenu getSessionIssuerMenu(ButtonGroup buttonGroup) { JRadioButtonMenuItem mnuSiType = new JRadioButtonMenuItem("Type"); JRadioButtonMenuItem mnuSiArn = new JRadioButtonMenuItem("Arn"); JRadioButtonMenuItem mnuSiPrincipalId = new JRadioButtonMenuItem("Principal Id"); JRadioButtonMenuItem mnuSiAccountId = new JRadioButtonMenuItem("Account Id"); JRadioButtonMenuItem mnuSiUsername = new JRadioButtonMenuItem("Username"); mnuSiType.setActionCommand("UserIdentity.SessionContext.SessionIssuer.Type"); mnuSiType.addActionListener(this); mnuSiPrincipalId.setActionCommand("UserIdentity.SessionContext.SessionIssuer.PrincipalId"); mnuSiPrincipalId.addActionListener(this); mnuSiArn.setActionCommand("UserIdentity.SessionContext.SessionIssuer.Arn"); mnuSiArn.addActionListener(this); mnuSiAccountId.setActionCommand("UserIdentity.SessionContext.SessionIssuer.AccountId"); mnuSiAccountId.addActionListener(this); mnuSiUsername.setActionCommand("UserIdentity.SessionContext.SessionIssuer.UserName"); mnuSiUsername.addActionListener(this); buttonGroup.add(mnuSiType);//from w w w . j a va2 s .co m buttonGroup.add(mnuSiPrincipalId); buttonGroup.add(mnuSiArn); buttonGroup.add(mnuSiAccountId); buttonGroup.add(mnuSiUsername); JMenu siMenu = new JMenu("Session Issuer"); siMenu.add(mnuSiType); siMenu.add(mnuSiPrincipalId); siMenu.add(mnuSiArn); siMenu.add(mnuSiAccountId); siMenu.add(mnuSiUsername); return siMenu; }
From source file:org.simbrain.plot.scatterplot.ScatterPlotGui.java
/** * Creates the menu bar.//from w ww . j a v a 2s . c o m */ private void createAttachMenuBar() { JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); for (Action action : actionManager.getOpenSavePlotActions()) { fileMenu.add(action); } fileMenu.addSeparator(); fileMenu.add(new CloseAction(this.getWorkspaceComponent())); JMenu editMenu = new JMenu("Edit"); JMenuItem preferences = new JMenuItem("Preferences..."); preferences.addActionListener(this); preferences.setActionCommand("dialog"); editMenu.add(preferences); JMenu helpMenu = new JMenu("Help"); ShowHelpAction helpAction = new ShowHelpAction("Pages/Plot/scatter_plot.html"); JMenuItem helpItem = new JMenuItem(helpAction); helpMenu.add(helpItem); bar.add(fileMenu); bar.add(editMenu); bar.add(helpMenu); getParentFrame().setJMenuBar(bar); }