Example usage for javax.swing JMenu menuSelectionChanged

List of usage examples for javax.swing JMenu menuSelectionChanged

Introduction

In this page you can find the example usage for javax.swing JMenu menuSelectionChanged.

Prototype

public void menuSelectionChanged(boolean isIncluded) 

Source Link

Document

Messaged when the menubar selection changes to activate or deactivate this menu.

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);//from w ww  .  j a v  a  2  s . c  o m

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    menu.add(new JMenuItem("Exit"));

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    menu.menuSelectionChanged(false);
}