Example usage for javax.swing JMenuItem isVisible

List of usage examples for javax.swing JMenuItem isVisible

Introduction

In this page you can find the example usage for javax.swing JMenuItem isVisible.

Prototype

@Transient
public boolean isVisible() 

Source Link

Document

Determines whether this component should be visible when its parent is visible.

Usage

From source file:processing.app.Base.java

private static JMenuItem selectVisibleSelectedOrFirstMenuItem(JMenu menu) {
    JMenuItem firstVisible = null;
    for (int i = 0; i < menu.getItemCount(); i++) {
        JMenuItem item = menu.getItem(i);
        if (item != null && item.isVisible()) {
            if (item.isSelected()) {
                return item;
            }//from w w  w .j  av a2  s .c  om
            if (firstVisible == null) {
                firstVisible = item;
            }
        }
    }

    if (firstVisible != null) {
        return firstVisible;
    }

    throw new IllegalStateException("Menu has no enabled items");
}