Z Codes
Z Codes

Reputation: 11

Is there any way to remove this search icon and bar from JMenuBar using Substance?

I am working with Substance and Swing, and learnt that when x amount of menu and sub menu items are added into a menu, Substance automatically will go ahead and add a magnifying glass icon and a search bar on the menu bar for you. It's useful for searching through the menus to find items quicker, but unfortunately I do not want this as I didn't design my user interface to have room for it. Is there any way to remove this?

public class SubstanceMenu {
    public JMenuBar createMenuBar() {
        JMenuBar menuBar = new JMenuBar();

        for (int i = 0; i < 4; i++) {
            JMenu menu = new JMenu("A Menu");
            JMenu subMenu = new JMenu("A submenu");

            for (int j = 0; j < 5; j++) {
                menu.add("Menu item");
                subMenu.add("Sub Menu Item");
            }

            menu.add(subMenu);
            menuBar.add(menu);
        }

        return menuBar;
    }

    private static void createAndShowGUI() {
        JFrame frame = new JFrame("MenuSelectionManagerDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        SubstanceMenu demo = new SubstanceMenu();
        frame.setJMenuBar(demo.createMenuBar());
        frame.setSize(450, 260);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(
                "org.jvnet.substance.skin.SubstanceMagmaLookAndFeel");
            SwingUtilities.invokeLater(() -> createAndShowGUI());
        } catch (Exception e) {
           e.printStackTrace();
        }
    }
}

How can I remove the icon/bar?

enter image description here

Upvotes: 1

Views: 80

Answers (1)

Kirill
Kirill

Reputation: 938

Developer of Substance here.

Looks like you're using a really old version of Substance (based on the "org.jvnet" package name of the look-and-feel class). The latest releases of Substance (now part of Radiance) are available at https://github.com/kirill-grouchnikov/radiance and do not add menu search widgets unless explicitly configured in the application code.

Upvotes: 1

Related Questions