Java Code Examples for javax.swing.JMenuItem#setOpaque()

The following examples show how to use javax.swing.JMenuItem#setOpaque() . 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: DebugUtils.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add an "add goods" menu item to a unit menu.
 *
 * @param fcc The enclosing {@code FreeColClient}.
 * @param unit The {@code Unit} to add goods to.
 * @param menu The {@code JPopupMenu} to add the entry to.
 */
public static void addGoodsAdditionEntry(final FreeColClient fcc,
                                         final Unit unit, JPopupMenu menu) {
    JMenuItem addg = new JMenuItem("Add goods");
    addg.setOpaque(false);
    addg.addActionListener((ActionEvent ae) -> {
            DebugUtils.addUnitGoods(fcc, unit);
        });
    addg.setEnabled(true);
    menu.add(addg);
}
 
Example 2
Source File: SwingSet3.java    From littleluck with Apache License 2.0 5 votes vote down vote up
protected JMenuBar createMenuBar() {

    JMenuBar menubar = new JMenuBar();
    menubar.setName("menubar");
    
    // File menu
    JMenu fileMenu = new JMenu();
    fileMenu.setName("file");
    menubar.add(fileMenu);
    
    // File -> Quit
    if (!runningOnMac()) {
        JMenuItem quitItem = new LuckMenuItem();
        quitItem.setOpaque(true);
        quitItem.setName("quit");
        quitItem.setAction(getAction("quit"));
        fileMenu.add(quitItem);
    }
   
    // View menu
    JMenu viewMenu = new JMenu();
    viewMenu.setName("view");
    // View -> Look and Feel       
    viewMenu.add(createLookAndFeelMenu());
    // View -> Source Code Visible
    sourceCodeCheckboxItem = new LuckCheckBoxMenuItem();
    sourceCodeCheckboxItem.setSelected(isSourceCodeVisible());
    sourceCodeCheckboxItem.setName("sourceCodeCheckboxItem");
    sourceCodeCheckboxItem.addChangeListener(new SourceVisibilityChangeListener());
    viewMenu.add(sourceCodeCheckboxItem);
    menubar.add(viewMenu);

    return menubar;
}
 
Example 3
Source File: MenuFactory.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private static void setMenuProperties(JMenuItem menuItem) {
	menuItem.setOpaque(false);
	menuItem.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
	menuItem.setForeground(ColorPalette.FOREGROUND_COLOR);
	menuItem.setFont(Fonts.FONT);
	menuItem.setCursor(Cursors.CURSOR);
}
 
Example 4
Source File: ProfilerPopupMenu.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public JMenuItem add(JMenuItem menuItem) {
    if (forceBackground && !UIUtils.isOracleLookAndFeel()) menuItem.setOpaque(false);
    return super.add(menuItem);
}
 
Example 5
Source File: ProfilerPopupMenu.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public JMenuItem add(JMenuItem menuItem) {
    if (forceBackground && !UIUtils.isOracleLookAndFeel()) menuItem.setOpaque(false);
    if (forceBackground && !UIUtils.isNimbusLookAndFeel()) menuItem.setForeground(getForeground());
    return super.add(menuItem);
}