List of usage examples for javax.swing JFrame setJMenuBar
@BeanProperty(bound = false, hidden = true, description = "The menubar for accessing pulldown menus from this frame.") public void setJMenuBar(final JMenuBar menubar)
From source file:MenuExample.java
public static void main(String s[]) { MenuExample example = new MenuExample(); example.pane = new JTextPane(); example.pane.setPreferredSize(new Dimension(250, 250)); example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED)); JFrame frame = new JFrame("Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(example.menuBar); frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack();/*from w ww.jav a 2 s . c om*/ frame.setVisible(true); }
From source file:CheckBoxMenuItemExample.java
public static void main(String s[]) { CheckBoxMenuItemExample example = new CheckBoxMenuItemExample(); example.pane = new JTextPane(); example.pane.setPreferredSize(new Dimension(250, 250)); example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED)); JFrame frame = new JFrame("Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(example.menuBar); frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack();/*w ww . j ava 2 s.c o m*/ frame.setVisible(true); }
From source file:RadioButtonMenuItemExample.java
public static void main(String s[]) { RadioButtonMenuItemExample example = new RadioButtonMenuItemExample(); example.pane = new JTextPane(); example.pane.setPreferredSize(new Dimension(250, 250)); example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED)); JFrame frame = new JFrame("Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(example.menuBar); frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack();// w w w .j a v a2s. c o m frame.setVisible(true); }
From source file:IntroExample.java
public static void main(String s[]) { JFrame frame = new JFrame("Simple Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(new IntroExample()); frame.pack();//from w w w .jav a 2 s .c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Main swapper = new Main(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(swapper.getMainPanel()); frame.setJMenuBar(swapper.getMenuBar()); frame.pack();/*from w w w .java2s . c om*/ frame.setLocationByPlatform(true); frame.setVisible(true); }
From source file:BorderLayoutExample.java
public static void main(String[] args) { JFrame f = new JFrame(); JMenuBar menubar = new JMenuBar(); JMenu file = new JMenu("File"); menubar.add(file);//from www. j a v a 2 s . c om f.setJMenuBar(menubar); JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); JButton bexit = new JButton(new ImageIcon("exit.png")); bexit.setBorder(new EmptyBorder(0, 0, 0, 0)); toolbar.add(bexit); f.add(toolbar, BorderLayout.NORTH); JToolBar vertical = new JToolBar(JToolBar.VERTICAL); vertical.setFloatable(false); vertical.setMargin(new Insets(10, 5, 5, 5)); JButton selectb = new JButton(new ImageIcon("a.png")); selectb.setBorder(new EmptyBorder(3, 0, 3, 0)); JButton freehandb = new JButton(new ImageIcon("b.png")); freehandb.setBorder(new EmptyBorder(3, 0, 3, 0)); JButton shapeedb = new JButton(new ImageIcon("c.png")); shapeedb.setBorder(new EmptyBorder(3, 0, 3, 0)); vertical.add(selectb); vertical.add(freehandb); vertical.add(shapeedb); f.add(vertical, BorderLayout.WEST); f.add(new JTextArea(), BorderLayout.CENTER); JLabel statusbar = new JLabel(" Statusbar"); statusbar.setPreferredSize(new Dimension(-1, 22)); statusbar.setBorder(LineBorder.createGrayLineBorder()); f.add(statusbar, BorderLayout.SOUTH); f.setSize(350, 300); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:ToolBarExample.java
public static void main(String s[]) { ToolBarExample example = new ToolBarExample(); example.pane = new JTextPane(); example.pane.setPreferredSize(new Dimension(250, 250)); example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED)); example.toolBar.setMaximumSize(example.toolBar.getSize()); JFrame frame = new JFrame("Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(example.menuBar); frame.getContentPane().add(example.toolBar, BorderLayout.NORTH); frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack();/*from w w w.jav a 2s .c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Menu Bar Demo"); JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu editMenu = new JMenu("Edit"); JMenu helpMenu = new JMenu("Help"); bar.add(fileMenu);//w ww . java 2 s .co m bar.add(editMenu); bar.add(helpMenu); frame.setSize(300, 150); frame.setJMenuBar(bar); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);//w w w . j a va2 s .c o m frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setSelected(true); }
From source file:SimpleMenu.java
/** A simple test program for the above code */ public static void main(String[] args) { // Get the locale: default, or specified on command-line Locale locale;/* w w w. j a va 2 s.c o m*/ if (args.length == 2) locale = new Locale(args[0], args[1]); else locale = Locale.getDefault(); // Get the resource bundle for that Locale. This will throw an // (unchecked) MissingResourceException if no bundle is found. ResourceBundle bundle = ResourceBundle.getBundle("com.davidflanagan.examples.i18n.Menus", locale); // Create a simple GUI window to display the menu with final JFrame f = new JFrame("SimpleMenu: " + // Window title locale.getDisplayName(Locale.getDefault())); JMenuBar menubar = new JMenuBar(); // Create a menubar. f.setJMenuBar(menubar); // Add menubar to window // Define an action listener for that our menu will use. ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { String s = e.getActionCommand(); Component c = f.getContentPane(); if (s.equals("red")) c.setBackground(Color.red); else if (s.equals("green")) c.setBackground(Color.green); else if (s.equals("blue")) c.setBackground(Color.blue); } }; // Now create a menu using our convenience routine with the resource // bundle and action listener we've created JMenu menu = SimpleMenu.create(bundle, "colors", new String[] { "red", "green", "blue" }, listener); // Finally add the menu to the GUI, and pop it up menubar.add(menu); // Add the menu to the menubar f.setSize(300, 150); // Set the window size. f.setVisible(true); // Pop the window up. }