Example usage for javax.swing JMenu isTopLevelMenu

List of usage examples for javax.swing JMenu isTopLevelMenu

Introduction

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

Prototype

@BeanProperty(bound = false)
public boolean isTopLevelMenu() 

Source Link

Document

Returns true if the menu is a 'top-level menu', that is, if it is the direct child of a menubar.

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);//  w w w . j a v  a  2  s .c  om

    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.isTopLevelMenu();
}