Search in sources :

Example 71 with JMenuBar

use of javax.swing.JMenuBar in project JMRI by JMRI.

the class JmriJFrame method addNotify.

@Override
public void addNotify() {
    super.addNotify();
    // log.debug("addNotify window ({})", getTitle());
    if (mShown) {
        return;
    }
    // resize frame to account for menubar
    JMenuBar jMenuBar = getJMenuBar();
    if (jMenuBar != null) {
        int jMenuBarHeight = jMenuBar.getPreferredSize().height;
        Dimension dimension = getSize();
        dimension.height += jMenuBarHeight;
        setSize(dimension);
    }
    mShown = true;
}
Also used : Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar)

Example 72 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class ScreenMenuMemoryLeakTest method showUI.

private static void showUI() {
    sFrame = new JFrame();
    sFrame.add(new JLabel("Some dummy content"));
    JMenuBar menuBar = new JMenuBar();
    sMenu = new JMenu("Menu");
    JMenuItem item = new JMenuItem("Item");
    sMenu.add(item);
    sMenuItem = new WeakReference<>(item);
    menuBar.add(sMenu);
    sFrame.setJMenuBar(menuBar);
    sFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    sFrame.pack();
    sFrame.setVisible(true);
}
Also used : JFrame(javax.swing.JFrame) JLabel(javax.swing.JLabel) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 73 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 74 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class MenuItemIconTest method createUI.

private static void createUI() throws Exception {
    SwingUtilities.invokeAndWait(() -> {
        frame = new JFrame();
        frame.setTitle("Test");
        JMenuBar menuBar = new JMenuBar();
        ImageIcon icon = createIcon();
        menuItem = new JMenuItem("Command", icon);
        menuItem.setHorizontalTextPosition(SwingConstants.LEFT);
        menuBar.add(menuItem);
        frame.setJMenuBar(menuBar);
        frame.setPreferredSize(new Dimension(500, 500));
        frame.pack();
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar)

Example 75 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class bug8071705 method createGUI.

private static JFrame createGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("Some menu");
    menuBar.add(menu);
    for (int i = 0; i < 10; i++) {
        menu.add(new JMenuItem("Some menu #" + i));
    }
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setMinimumSize(new Dimension(200, 200));
    frame.setJMenuBar(menuBar);
    return frame;
}
Also used : JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) Point(java.awt.Point)

Aggregations

JMenuBar (javax.swing.JMenuBar)119 JMenu (javax.swing.JMenu)83 JMenuItem (javax.swing.JMenuItem)45 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)30 JPanel (javax.swing.JPanel)28 BoxLayout (javax.swing.BoxLayout)25 Dimension (java.awt.Dimension)23 JFrame (javax.swing.JFrame)17 JScrollPane (javax.swing.JScrollPane)15 JLabel (javax.swing.JLabel)14 JButton (javax.swing.JButton)13 JmriJFrame (jmri.util.JmriJFrame)12 GridBagLayout (java.awt.GridBagLayout)11 BorderLayout (java.awt.BorderLayout)10 JSeparator (javax.swing.JSeparator)10 AbstractAction (javax.swing.AbstractAction)9 FlowLayout (java.awt.FlowLayout)6 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)6 JPopupMenu (javax.swing.JPopupMenu)6