javax.swing.JMenuBar Java Examples

The following examples show how to use javax.swing.JMenuBar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwingUtils.java    From IBC with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Traverses a container hierarchy and returns the JMenuItem with
 * the given path from the first JMenuBar that contains it
 *
 * @param container
 *  the Container to search in
 * @param path
 *  the required menu path
 * @return
 *  the JMenuItem at the specified path, if found; otherwise null
 */
static JMenuItem findMenuItemInAnyMenuBar(Container container, String[] path) {
    if (path.length == 0) return null;

    int i = 0;
    while (true) {
        JMenuBar menuBar = findMenuBar(container, i);
        if (menuBar == null) {
            String s = path[0];
            for (int j = 1; j < path.length; j++) s = s + " > " + path[j];
            return null;
        }
        JMenuItem menuItem = findMenuItem(menuBar, path);
        if (menuItem != null) return menuItem;
        i++;
    }
}
 
Example #2
Source File: SwingUtils.java    From IBC with GNU General Public License v3.0 6 votes vote down vote up
private static void appendMenuItem(Component menuItem, StringBuilder builder, String indent) {
    if (menuItem instanceof JMenuBar) {
        appendMenuSubElements((MenuElement)menuItem, builder, indent);
    } else if (menuItem instanceof JPopupMenu) {
        appendMenuSubElements((MenuElement)menuItem, builder, indent);
    } else if (menuItem instanceof JMenuItem) {
        builder.append(NEWLINE);
        builder.append(indent);
        builder.append(((JMenuItem)menuItem).getText());
        builder.append(((JMenuItem)menuItem).isEnabled() ? "" : "[Disabled]");
        appendMenuSubElements((JMenuItem)menuItem, builder, "|   " + indent);
    } else if (menuItem instanceof JSeparator) {
        builder.append(NEWLINE);
        builder.append(indent);
        builder.append("--------");
    }
}
 
Example #3
Source File: MenuChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Get MenuBar and tranfer it to ArrayList.
     * @param menu menu to be tranfered
     * @return tranfered menubar */
    private static List<NbMenu> getMenuBarArrayList(JMenuBar menu) {
        visitMenuBar(menu);

        MenuElement [] elements = menu.getSubElements();

        List<NbMenu> list = new ArrayList<NbMenu>();
        for(int k=0; k < elements.length; k++) {
//            if(elements[k] instanceof JMenuItem) {
//                list.add(new NbMenu((JMenuItem)elements[k], null));
                JMenuBarOperator menuOp = new JMenuBarOperator(menu);
                JMenu item = menuOp.getMenu(k);
                list.add(new NbMenu(item, getMenuArrayList(item)));
//            }
            /*if(elements[k] instanceof JMenuBar) {
                JMenuBarOperator menuOp = new JMenuBarOperator(menu);
                list.add(getMenuArrayList(menuOp.getMenu(0)));
            }
             */
        }
        return list;
    }
 
Example #4
Source File: Main.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
public static JFrame launch(Component contents, JMenuBar menuBar) {
   window = new JFrame("Oculus");
   window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   if(menuBar != null) {
      window.setJMenuBar(menuBar);
   }
   window.setLayout(new BorderLayout());
   window.getContentPane().add(createNotificationPanel(), BorderLayout.NORTH);
   window.getContentPane().add(contents, BorderLayout.CENTER);
   window.getContentPane().add(createStatusPanel(), BorderLayout.SOUTH);

   int width = 1400;
   int height = 1000;
   Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
   window.setBounds((int)screen.getWidth()/2 - width/2, (int)screen.getHeight()/2 - height/2, width, height);
   window.setLocationByPlatform(true);

   window.setVisible(true);
   Oculus.setMainWindow(window);
   return window;
}
 
Example #5
Source File: MainFrame.java    From FCMFrame with Apache License 2.0 6 votes vote down vote up
public JMenuBar createMenus() {
	JMenuBar menuBar = new JMenuBar();
	menuBar.getAccessibleContext().setAccessibleName("");

	JMenu fileMenu = (JMenu) menuBar.add(new JMenu("文件"));
	createMenuItem(fileMenu, "打开文件", "", "", new OpenFileAction());
	fileMenu.addSeparator();
	createMenuItem(fileMenu, "保存", "", "", new SaveFileAction());
	createMenuItem(fileMenu, "另存为...", "", "", new SaveAsFileAction());
	fileMenu.addSeparator();
	createMenuItem(fileMenu, "保存界面为图片...", "", "", new SaveAsPictureAction());
	fileMenu.addSeparator();
	createMenuItem(fileMenu, "打开文件位置", "", "", new FilesLocationAction());
	fileMenu.addSeparator();
	createMenuItem(fileMenu, "退出系统", "", "", new ExitSys());
	
	JMenu preferenceMenu = (JMenu) menuBar.add(new JMenu("选项"));
	JMenuItem mi = createCheckBoxMenuItem(preferenceMenu, "显示网格", "", "", new CoordinateAction());
	mi.setSelected(true);

	return menuBar;
}
 
Example #6
Source File: bug8031573.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JMenuBar bar = new JMenuBar();
                JMenu menu = new JMenu("Menu");
                JCheckBoxMenuItem checkBoxMenuItem
                        = new JCheckBoxMenuItem("JCheckBoxMenuItem");
                checkBoxMenuItem.setSelected(true);
                menu.add(checkBoxMenuItem);
                bar.add(menu);
                setJMenuBar(bar);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #7
Source File: SwingUtils.java    From ib-controller with GNU General Public License v3.0 6 votes vote down vote up
private static void appendMenuItem(Component menuItem, StringBuilder builder, String indent) {
    if (menuItem instanceof JMenuBar) {
        appendMenuSubElements((MenuElement)menuItem, builder, indent);
    } else if (menuItem instanceof JPopupMenu) {
        appendMenuSubElements((MenuElement)menuItem, builder, indent);
    } else if (menuItem instanceof JMenuItem) {
        builder.append(NEWLINE);
        builder.append(indent);
        builder.append(((JMenuItem)menuItem).getText());
        builder.append(((JMenuItem)menuItem).isEnabled() ? "" : "[Disabled]");
        appendMenuSubElements((JMenuItem)menuItem, builder, "|   " + indent);
    } else if (menuItem instanceof JSeparator) {
        builder.append(NEWLINE);
        builder.append(indent);
        builder.append("--------");
    }
}
 
Example #8
Source File: CloseOnMouseClickPropertyTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void createAndShowGUI(TestItem testItem) {

        frame = new JFrame();
        frame.setSize(300, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JMenuBar menuBar = new JMenuBar();
        menu = new JMenu("Menu");
        JMenuItem menuItem = testItem.getMenuItem();
        testItem.setProperties(menuItem);
        menu.add(menuItem);
        menuBar.add(menu);

        frame.setJMenuBar(menuBar);
        frame.setVisible(true);
    }
 
Example #9
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
/**
 * Sets up the Control Panel's menu bar.
 */
private void initializeMenus() {

	// Set up the individual menus
	this.initializeFileMenu();
	this.initializeEditMenu();
	this.initializeToolsMenu();
	this.initializeWindowMenu();
	this.initializeOptionsMenu();
	this.initializeUnitsMenu();
	this.initializeHelpMenu();

	// Add the individual menu to the main menu
	JMenuBar mainMenuBar = new JMenuBar();
	mainMenuBar.add( fileMenu );
	mainMenuBar.add( editMenu );
	mainMenuBar.add( toolsMenu );
	mainMenuBar.add( viewsMenu );
	mainMenuBar.add( optionMenu );
	mainMenuBar.add( unitsMenu );
	mainMenuBar.add( helpMenu );

	// Add main menu to the window
	setJMenuBar( mainMenuBar );
}
 
Example #10
Source File: MenuItemIconTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    });
}
 
Example #11
Source File: AppleMenuDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void activateMenu(JMenuBar bar) {
    if (getSelectedElement(bar) == null) {
        tryToActivate();
        if (getSelectedElement(bar) == null) {
            tryToActivate();
        }
    }
}
 
Example #12
Source File: MisplacedBorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws standard JMenuBar.
 */
private BufferedImage step1(final JMenuBar menubar) {
    final BufferedImage bi1 = new BufferedImage(W, H, TYPE_INT_ARGB_PRE);
    final Graphics2D g2d = bi1.createGraphics();
    g2d.scale(2, 2);
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, W, H);
    menubar.paintAll(g2d);
    g2d.dispose();
    return bi1;
}
 
Example #13
Source File: Editor.java    From Cafebabe with GNU General Public License v3.0 5 votes vote down vote up
private JMenuBar createMenu() {
	JMenuBar mb = new JMenuBar();
	JMenu actions = new JMenu(Translations.get("Actions"));
	JMenuItem close = new JMenuItem(Translations.get("Close all"));
	close.addActionListener(l -> {
		pane.closeAll();
	});

	actions.add(close);
	mb.add(actions);
	return mb;
}
 
Example #14
Source File: JMenuBarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Hashtable<String, Object> getDump() {
    Hashtable<String, Object> result = super.getDump();
    String[] items = new String[((JMenuBar) getSource()).getMenuCount()];
    for (int i = 0; i < ((JMenuBar) getSource()).getMenuCount(); i++) {
        if (((JMenuBar) getSource()).getMenu(i) != null) {
            items[i] = ((JMenuBar) getSource()).getMenu(i).getText();
        } else {
            items[i] = "null";
        }
    }
    addToDump(result, SUBMENU_PREFIX_DPROP, items);
    return result;
}
 
Example #15
Source File: DateTimeBrowser.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void go(String[] args) {

        mainArgs = args;
        setDefaultTimeZone();   // let user override if needed
        // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        //
        JMenuBar menuBar = new JMenuBar();
        setJMenuBar( menuBar );
        addMenus( menuBar );
        /*
         * Add a fast close listener
         */

        addWindowListener( new WindowAdapter() {
                    public void windowClosing(WindowEvent e)
                    {
                        setVisible( false );
                        dispose();
                        System.exit(0);
                    }
                }
            );

        //
        // Load current file, prime tables and JFrame.
        //
        currFile = new LoadedFile( mainArgs[0] );
        TableView tView = getDefaultTableView();
        resetDefaults( tView );
        //
        // Set max size at start, and display the window.
        //
        Dimension screenMax = Toolkit.getDefaultToolkit().getScreenSize();
        setSize ( screenMax );
        setVisible(true);
    }
 
Example #16
Source File: MisplacedBorder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws standard JMenuBar.
 */
private BufferedImage step1(final JMenuBar menubar) {
    final BufferedImage bi1 = new BufferedImage(W, H, TYPE_INT_ARGB_PRE);
    final Graphics2D g2d = bi1.createGraphics();
    g2d.scale(2, 2);
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, W, H);
    menubar.paintAll(g2d);
    g2d.dispose();
    return bi1;
}
 
Example #17
Source File: Hiero.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void initializeMenus () {
	{
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		{
			JMenu fileMenu = new JMenu();
			menuBar.add(fileMenu);
			fileMenu.setText("File");
			fileMenu.setMnemonic(KeyEvent.VK_F);
			{
				openMenuItem = new JMenuItem("Open Hiero settings file...");
				openMenuItem.setMnemonic(KeyEvent.VK_O);
				openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK));
				fileMenu.add(openMenuItem);
			}
			{
				saveMenuItem = new JMenuItem("Save Hiero settings file...");
				saveMenuItem.setMnemonic(KeyEvent.VK_S);
				saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK));
				fileMenu.add(saveMenuItem);
			}
			fileMenu.addSeparator();
			{
				saveBMFontMenuItem = new JMenuItem("Save BMFont files (text)...");
				saveBMFontMenuItem.setMnemonic(KeyEvent.VK_B);
				saveBMFontMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK));
				fileMenu.add(saveBMFontMenuItem);
			}
			fileMenu.addSeparator();
			{
				exitMenuItem = new JMenuItem("Exit");
				exitMenuItem.setMnemonic(KeyEvent.VK_X);
				fileMenu.add(exitMenuItem);
			}
		}
	}
}
 
Example #18
Source File: WindowsRootPaneUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
Example #19
Source File: Canvas.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new frame with a given menu bar and bounds.
 *
 * @param menuBar The new frames {@code JMenuBar}.
 * @param windowBounds The new frame bounding {@code Rectangle}.
 * @return The new {@code FreeColFrame}.
 */
private FreeColFrame createFrame(JMenuBar menuBar, Rectangle windowBounds) {
    // FIXME: Check this:
    // User might have moved window to new screen in a
    // multi-screen setup, so make this.gd point to the current screen.
    FreeColFrame fcf
        = new FreeColFrame(this.freeColClient, this.graphicsDevice,
                           menuBar, isWindowed(), windowBounds);
    fcf.getContentPane().add(this);
    fcf.setVisible(true);
    return fcf;
}
 
Example #20
Source File: bug8071705.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #21
Source File: MnemonicFactory.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public static void setMnemonics(final JMenuBar menuBar) {
    final int c = menuBar.getMenuCount();
    final ArrayList<JMenuItem> list = new ArrayList<JMenuItem>(c);
    for (int i = 0; i < c; i++)
        list.add(menuBar.getMenu(i));
    setMnemonics(list);
}
 
Example #22
Source File: DTMF_Decoder.java    From DTMF-Decoder with MIT License 5 votes vote down vote up
/**
 * Create the applet.
 */
public DTMF_Decoder() {
	getContentPane().setLayout(null);
	
	JMenuBar menuBar = new JMenuBar();
	menuBar.setBounds(0, 0, 450, 21);
	getContentPane().add(menuBar);
	
	JMenu mnMenu = new JMenu("Menu");
	menuBar.add(mnMenu);
	
	JMenuItem mntmDecodeDtmf = new JMenuItem("Decode DTMF");
	mnMenu.add(mntmDecodeDtmf);
	
	JMenuItem mntmGenerateDtmf = new JMenuItem("Generate DTMF");
	mnMenu.add(mntmGenerateDtmf);
	
	JMenu mnAbout = new JMenu("About");
	menuBar.add(mnAbout);
	
	JMenuItem mntmLicense = new JMenuItem("License");
	mnAbout.add(mntmLicense);
	
	JMenuItem mntmAbout = new JMenuItem("About");
	mnAbout.add(mntmAbout);
	
	JButton btnDecodeDtmf = new JButton("Decode DTMF");
	btnDecodeDtmf.setBounds(12, 49, 179, 74);
	getContentPane().add(btnDecodeDtmf);
	
	JButton btnGenrateDtmf = new JButton("Generate DTMF");
	btnGenrateDtmf.setBounds(203, 49, 179, 74);
	getContentPane().add(btnGenrateDtmf);

}
 
Example #23
Source File: SilenceOfDeprecatedMenuBar.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected JRootPane createRootPane() {
    return new JRootPane() {
        @Override
        public JMenuBar getMenuBar() {
            throw new RuntimeException("Should not be here");
        }
        @Override
        public void setMenuBar(final JMenuBar menu) {
            throw new RuntimeException("Should not be here");
        }
    };
}
 
Example #24
Source File: JMenuBarOverlapping.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void prepareControls() {
    frame = new JFrame("Mixing : Dropdown Overlapping test");
    frame.setLayout(new GridLayout(0,1));
    frame.setSize(200, 200);
    frame.setVisible(true);

    menuBar = new JMenuBar();
    JMenu menu = new JMenu("Test Menu");
    ActionListener menuListener = new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            lwClicked = true;
        }
    };

    JMenuItem item;
    menu.add(item = new JMenuItem("first"));
    item.addActionListener(menuListener);
    separator = new JSeparator();
    separator.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            spClicked = true;
        }
    });
    menu.add(separator);

    for (int i = 0; i < petStrings.length; i++) {
        menu.add(item = new JMenuItem(petStrings[i]));
        item.addActionListener(menuListener);
    }
    menuBar.add(menu);
    frame.setJMenuBar(menuBar);

    propagateAWTControls(frame);
    frame.setVisible(true);
}
 
Example #25
Source File: bug8071705.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #26
Source File: MisplacedBorder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example #27
Source File: MenuEditLayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static boolean isMenuRelatedComponentClass(Class clas) {
    if(clas == null) return false;
    if(JMenuItem.class.isAssignableFrom(clas)) return true;
    if(JMenu.class.isAssignableFrom(clas)) return true;
    if(JSeparator.class.isAssignableFrom(clas)) return true;
    if(JMenuBar.class.isAssignableFrom(clas)) return true;
    return false;
}
 
Example #28
Source File: SetWidgetVisible.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates the main frame for <code>this</code> sample.
 */
public SetWidgetVisible() {
    super("Set widget visible");

    this.setLayout(new BorderLayout());

    // create sample menu bar with two menus
    JMenuBar jmb = new JMenuBar();
    JMenu menu = new JMenu("menu");
    menu.add(new JMenuItem("test item 1"));
    menu.add(new JMenuItem("test item 2"));
    menu.add(new JMenuItem("test item 3"));
    menu.addSeparator();
    menu.add(new JMenuItem("test menu item 4"));
    menu.add(new JMenuItem("test menu item 5"));
    menu.add(new JMenuItem("test menu item 6"));
    jmb.add(menu);

    JMenu menu2 = new JMenu("big");
    for (int i = 0; i < 35; i++)
        menu2.add(new JMenuItem("menu item " + i));
    jmb.add(menu2);

    this.setJMenuBar(jmb);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JCheckBox showMenuSearchPanels = new JCheckBox("Show menu search panels");
    showMenuSearchPanels.setSelected(false);
    showMenuSearchPanels.addActionListener((ActionEvent e) -> SwingUtilities.invokeLater(
            () -> SubstanceCortex.WindowScope.setWidgetVisible(SetWidgetVisible.this,
                    showMenuSearchPanels.isSelected(), SubstanceWidgetType.MENU_SEARCH)));
    controls.add(showMenuSearchPanels);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400, 200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example #29
Source File: JMenuBarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JMenuBar.isBorderPainted()} through queue
 */
public boolean isBorderPainted() {
    return (runMapping(new MapBooleanAction("isBorderPainted") {
        @Override
        public boolean map() {
            return ((JMenuBar) getSource()).isBorderPainted();
        }
    }));
}
 
Example #30
Source File: MainFrameView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
private void initMenuBar() {
	menuBar = new JMenuBar();

	JMenu menuFile = new JMenu(Messages.get("term.appTitle"));
	menuFile.add(miChangeTempFolderForDecrypted = new JMenuItem());
	menuFile.addSeparator();
	menuFile.add(miAbout = new JMenuItem());
	menuFile.add(miCheckForUpdates = new JMenuItem());
	menuFile.add(miAutoCheckForUpdates = new JCheckBoxMenuItem());
	menuFile.addSeparator();
	menuFile.add(miFaq = new JMenuItem());
	menuFile.add(miHelp = new JMenuItem());
	menuFile.add(miBmc = new JMenuItem());
	menuFile.addSeparator();
	menuFile.add(miConfigExit = new JMenuItem());

	JMenu menuKeyring = new JMenu(Messages.get("term.keyring"));
	menuKeyring.add(miShowKeyList = new JMenuItem());
	menuKeyring.addSeparator();
	menuKeyring.add(miPgpImportKey = new JMenuItem());
	menuKeyring.add(miPgpImportKeyFromText = new JMenuItem());
	menuKeyring.add(miPgpCreateKey = new JMenuItem());

	JMenu menuActions = new JMenu(Messages.get("term.actions"));
	menuActions.add(miEncrypt = new JMenuItem());
	menuActions.add(miEncryptText = new JMenuItem());
	menuActions.addSeparator();
	menuActions.add(miDecrypt = new JMenuItem());
	menuActions.add(miDecryptText = new JMenuItem());
	menuActions.addSeparator();
	menuActions.add(miEncryptBackAll = new JMenuItem());

	menuBar.add(menuFile);
	menuBar.add(menuKeyring);
	menuBar.add(menuActions);
}