Example usage for javax.swing JFrame setJMenuBar

List of usage examples for javax.swing JFrame setJMenuBar

Introduction

In this page you can find the example usage for javax.swing JFrame setJMenuBar.

Prototype

@BeanProperty(bound = false, hidden = true, description = "The menubar for accessing pulldown menus from this frame.")
public void setJMenuBar(final JMenuBar menubar) 

Source Link

Document

Sets the menubar for this frame.

Usage

From source file:Main.java

public static void addMenuAt(JFrame frame, JMenu newMenu, int index) {
    frame.setJMenuBar(addMenuAt(newMenu, frame.getJMenuBar(), index));
}

From source file:QandE.MyDemo2.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./* w  ww. j av  a2 s. c  o m*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MyDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenu menu = new JMenu("Menu");
    JMenuBar mb = new JMenuBar();
    mb.add(menu);
    frame.setJMenuBar(mb);

    //Add a label with bold italic font.
    JLabel label = new JLabel("My Demo");
    frame.getContentPane().add(BorderLayout.CENTER, label);
    if (true) {
        label.setFont(label.getFont().deriveFont(Font.ITALIC | Font.BOLD));
    } else {
        //another way of doing it, but not as appropriate since 
        //setFont is faster than using HTML.
        label.setText("<html><i>My Demo</i></html>");
    }
    label.setHorizontalAlignment(JLabel.CENTER);

    //Display the window, making it a little bigger than it really needs to be.
    frame.pack();
    frame.setSize(frame.getWidth() + 100, frame.getHeight() + 50);
    frame.setVisible(true);
}

From source file:dnd.TextCutPaste.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.// w ww  .  jav  a  2s . c o  m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("TextCutPaste");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the menu bar and content pane.
    TextCutPaste demo = new TextCutPaste();
    frame.setJMenuBar(demo.createMenuBar());
    demo.setOpaque(true); //content panes must be opaque
    frame.setContentPane(demo);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:components.MenuLookDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from w w  w  .  j  a v a 2s .co m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MenuLookDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    MenuLookDemo demo = new MenuLookDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    //Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}

From source file:MenuLookDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */// w ww  .j a  v a 2 s  .c  o  m
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("MenuLookDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    MenuLookDemo demo = new MenuLookDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}

From source file:components.MenuDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from w  w  w.j  a v a 2 s. c om
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    MenuDemo demo = new MenuDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    //Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}

From source file:dnd.ListCutPaste.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./*w  w w.  ja v  a  2 s . c o m*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("ListCutPaste");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the menu bar and content pane.
    ListCutPaste demo = new ListCutPaste();
    frame.setJMenuBar(demo.createMenuBar());
    demo.setOpaque(true); //content panes must be opaque
    frame.setContentPane(demo);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:MenuDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from  w w  w .  jav  a 2  s .  com
private static void createAndShowGUI() {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    //Create and set up the window.
    JFrame frame = new JFrame("MenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    MenuDemo demo = new MenuDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    //Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}

From source file:misc.ActionDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the 
 * event-dispatching thread.//w  w w.  j  a  va 2  s.c  om
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("ActionDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create/set menu bar and content pane.
    ActionDemo demo = new ActionDemo();
    frame.setJMenuBar(demo.createMenuBar());
    demo.createToolBar();
    demo.setOpaque(true); //content panes must be opaque
    frame.setContentPane(demo);

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:components.PopupMenuDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread./*from w w  w .  j  a v  a 2s  . c  o m*/
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("PopupMenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create/set menu bar and content pane.
    PopupMenuDemo demo = new PopupMenuDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    //Create and set up the popup menu.
    demo.createPopupMenu();

    //Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}