Substance API

View all API methods.

View all client properties.


API method

public static void showMenuSearchPanels()

Description

Shows menu search panels on all open frames. For each panel, the menu search panel will be shown only if the corresponding settings allow it.


See also


Sample code

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;

import test.Check;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#hideMenuSearchPanels()} and
 {@link SubstanceLookAndFeel#showMenuSearchPanels()} APIs.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#hideMenuSearchPanels()
 @see SubstanceLookAndFeel#showMenuSearchPanels()
 */
public class HideShowMenuSearchPanels extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public HideShowMenuSearchPanels() {
    super("Hide / show menu search panels");

    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", Check.getIcon("flag_mexico")));
    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", Check
            .getIcon("flag_sweden")));
    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(true);
    showMenuSearchPanels.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            if (showMenuSearchPanels.isSelected()) {
              SubstanceLookAndFeel.showMenuSearchPanels();
            else {
              SubstanceLookAndFeel.hideMenuSearchPanels();
            }
          }
        });
      }
    });
    controls.add(showMenuSearchPanels);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  /**
   * The main method for <code>this</code> sample. The arguments are
   * ignored.
   
   @param args
   *            Ignored.
   @throws Exception
   *             If some exception occured. Note that there is no special
   *             treatment of exception conditions in <code>this</code>
   *             sample code.
   */
  public static void main(String[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new HideShowMenuSearchPanels().setVisible(true);
      }
    });
  }
}

The screenshot below shows application frame with menu search panel not showing (after hideMenuSearchPanels has been called):

The screenshot below shows application frame after this API has been called - menu search panel is showing: