List of usage examples for javax.swing JMenuBar add
public JMenu add(JMenu c)
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();//w ww. ja va 2s. c o 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:InternalFrameTest.java
public DesktopFrame() { setTitle("InternalFrameTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); desktop = new JDesktopPane(); add(desktop, BorderLayout.CENTER); // set up menus JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar);/* www .j a va 2s . c o m*/ JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); JMenuItem openItem = new JMenuItem("New"); openItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { createInternalFrame(new JLabel(new ImageIcon(planets[counter] + ".gif")), planets[counter]); counter = (counter + 1) % planets.length; } }); fileMenu.add(openItem); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(exitItem); JMenu windowMenu = new JMenu("Window"); menuBar.add(windowMenu); JMenuItem nextItem = new JMenuItem("Next"); nextItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { selectNextWindow(); } }); windowMenu.add(nextItem); JMenuItem cascadeItem = new JMenuItem("Cascade"); cascadeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { cascadeWindows(); } }); windowMenu.add(cascadeItem); JMenuItem tileItem = new JMenuItem("Tile"); tileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { tileWindows(); } }); windowMenu.add(tileItem); final JCheckBoxMenuItem dragOutlineItem = new JCheckBoxMenuItem("Drag Outline"); dragOutlineItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { desktop.setDragMode(dragOutlineItem.isSelected() ? JDesktopPane.OUTLINE_DRAG_MODE : JDesktopPane.LIVE_DRAG_MODE); } }); windowMenu.add(dragOutlineItem); }
From source file:XMLWriteTest.java
public XMLWriteFrame() { setTitle("XMLWriteTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); chooser = new JFileChooser(); // add component to frame comp = new RectangleComponent(); add(comp);/*from www . j a v a 2 s . c om*/ // set up menu bar JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem newItem = new JMenuItem("New"); menu.add(newItem); newItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { comp.newDrawing(); } }); JMenuItem saveItem = new JMenuItem("Save with DOM/XSLT"); menu.add(saveItem); saveItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { saveDocument(); } catch (Exception e) { JOptionPane.showMessageDialog(XMLWriteFrame.this, e.toString()); } } }); JMenuItem saveStAXItem = new JMenuItem("Save with StAX"); menu.add(saveStAXItem); saveStAXItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { saveStAX(); } catch (Exception e) { JOptionPane.showMessageDialog(XMLWriteFrame.this, e.toString()); } } }); JMenuItem exitItem = new JMenuItem("Exit"); menu.add(exitItem); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); }
From source file:MainClass.java
public MainClass() { super();/*from w w w . j a v a2 s. c o m*/ setChannel(currentNumber); numberLabel.setHorizontalAlignment(JLabel.CENTER); numberLabel.setFont(new Font("Serif", Font.PLAIN, 32)); getContentPane().add(numberLabel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16)); getContentPane().add(buttonPanel, BorderLayout.CENTER); buttonPanel.add(new JButton(upAction)); buttonPanel.add(new JButton(gotoFavoriteAction)); buttonPanel.add(new JButton(downAction)); buttonPanel.add(new JButton(setFavoriteAction)); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("Number"); menu.add(new JMenuItem(upAction)); menu.add(new JMenuItem(downAction)); menu.addSeparator(); menu.add(new JMenuItem(gotoFavoriteAction)); menu.add(new JMenuItem(setFavoriteAction)); mb.add(menu); setJMenuBar(mb); }
From source file:net.brtly.monkeyboard.gui.MasterControlPanel.java
public MasterControlPanel(JFrame frame) { _frame = frame;/*w w w.j a va 2s . co m*/ initWindowListener(frame); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu mnActions = new JMenu("Actions"); menuBar.add(mnActions); JMenu mnDebug = new JMenu("Debug"); mnActions.add(mnDebug); JMenuItem mntmAddPluginpanel = new JMenuItem("Request null PluginPanel"); mntmAddPluginpanel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.out.println("Requesting null PluginPanel"); // TODO } }); mnDebug.add(mntmAddPluginpanel); JMenu mnOptions = new JMenu("Options"); menuBar.add(mnOptions); _viewMenu = new JMenu("Views"); _viewMenu.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent arg0) { } @Override public void menuDeselected(MenuEvent arg0) { } @Override public void menuSelected(MenuEvent arg0) { updateViewMenu(); } }); menuBar.add(_viewMenu); // INITIALIZE MANAGERS // TODO: maybe call this in the Runnable and fire an event when finished _eventBus = new SwingEventBus(); _eventBus.register(this); DeviceManager.init(_eventBus); _pluginManager = new PluginManager(_eventBus); _pluginManager.loadPlugins(); // create the status bar panel and shove it down the bottom of the frame statusPanel = new StatusBar(frame); _frame.getContentPane().add(statusPanel, BorderLayout.SOUTH); _dockController = new CControl(frame); _frame.getContentPane().add(_dockController.getContentArea(), BorderLayout.CENTER); _panelFactory = new PluginPanelDockableFactory(_pluginManager); _dockController.addMultipleDockableFactory(PluginPanelDockableFactory.ID, _panelFactory); _dockController.createWorkingArea("root"); updateViewMenu(); EventQueue.invokeLater(new Runnable() { @Override public void run() { DeviceManager.start(null); } }); _runOnClose.add(new Runnable() { public void run() { _dockController.destroy(); DeviceManager.stop(); DeviceManager.shutdown(); System.exit(0); } }); }
From source file:AddButtonToTabBar.java
public AddButtonToTabBar() { 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();/*w ww. j a v a 2 s .c om*/ } }; mi.addActionListener(addTabl); mFile.add(mi); mb.add(mFile); setJMenuBar(mb); JPanel pnlURL = new JPanel(); tp = new JTabbedPane(); addTab(); getContentPane().add(tp, BorderLayout.CENTER); lblStatus = new JLabel(" "); getContentPane().add(lblStatus, BorderLayout.SOUTH); setSize(300, 300); setVisible(true); }
From source file:ActionExampleSwing.java
public ActionExampleSwing() { super("ActionExample Swing"); setChannel(currentChannel); // enable/disable the Actions as appropriate channelLabel.setHorizontalAlignment(JLabel.CENTER); channelLabel.setFont(new Font("Serif", Font.PLAIN, 32)); getContentPane().add(channelLabel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16)); getContentPane().add(buttonPanel, BorderLayout.CENTER); buttonPanel.add(new JButton(upAction)); buttonPanel.add(new JButton(gotoFavoriteAction)); buttonPanel.add(new JButton(downAction)); buttonPanel.add(new JButton(setFavoriteAction)); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("Channel"); menu.add(new JMenuItem(upAction)); menu.add(new JMenuItem(downAction)); menu.addSeparator();/*from w w w . ja va2 s. co m*/ menu.add(new JMenuItem(gotoFavoriteAction)); menu.add(new JMenuItem(setFavoriteAction)); mb.add(menu); setJMenuBar(mb); }
From source file:SiteFrame.java
public PageFrame(String name, SiteManager sm) { super("Page: " + name, true, true, true, true); parent = sm;/* www .ja v a 2 s .c o m*/ setBounds(50, 50, 300, 150); Container contentPane = getContentPane(); // Create a text area to display the contents of our file in // and stick it in a scrollable pane so we can see everything ta = new JTextArea(); JScrollPane jsp = new JScrollPane(ta); contentPane.add(jsp, BorderLayout.CENTER); JMenuBar jmb = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem saveItem = new JMenuItem("Save"); saveItem.addActionListener(this); fileMenu.add(saveItem); jmb.add(fileMenu); setJMenuBar(jmb); filename = name; loadContent(); }
From source file:TabPanelwithImageIconCustom.java
public TabPanelwithImageIconCustom() { setSize(450, 350);// w w w . j a v a 2 s . c o m this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(textfield, BorderLayout.SOUTH); JMenuBar mbar = new JMenuBar(); JMenu menu = new JMenu("File"); menu.add(new JCheckBoxMenuItem("Check Me")); menu.addSeparator(); JMenuItem item = new JMenuItem("Exit"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menu.add(item); mbar.add(menu); setJMenuBar(mbar); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Button", new TabIcon(), new JButton(""), "Click here for Button demo"); }
From source file:Main.java
public Main() { setSize(450, 350);// w ww. ja v a 2s. co m this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(textfield, BorderLayout.SOUTH); JMenuBar mbar = new JMenuBar(); JMenu menu = new JMenu("File"); menu.add(new JCheckBoxMenuItem("Check Me")); menu.addSeparator(); JMenuItem item = new JMenuItem("Exit"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menu.add(item); mbar.add(menu); setJMenuBar(mbar); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Button", new TabIcon(), new JButton(""), "Click here for Button demo"); }