Example usage for javax.swing JMenu insert

List of usage examples for javax.swing JMenu insert

Introduction

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

Prototype

public JMenuItem insert(Action a, int pos) 

Source Link

Document

Inserts a new menu item attached to the specified Action object at a given position.

Usage

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ActionComponentManager.java

/**
 * Check and add menu item.//from  w w w  .j a  v  a2 s .c om
 *
 * @param menu the menu
 * @param menuItem the menu item
 * @param menuLocationIndex the menu location index
 */
private synchronized void checkAndAddMenuItem(JMenu menu, JMenuItem menuItem, int menuLocationIndex) {
    // check if menu has item count greater than menuLocationIndex
    int menuItemCount = menu.getItemCount();
    if (menuItemCount > menuLocationIndex) {
        menu.insert(menuItem, menuLocationIndex);
    } else {
        menu.insert(menuItem, menuItemCount);
    }

    //reset  quit menu item
    resetQuitMenuMenuItem();
}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ActionComponentManager.java

/**
 * Reset quit menu menu item./* w  ww  .  j a  va2s.  c o  m*/
 */
private synchronized void resetQuitMenuMenuItem() {
    // get file menu
    JMenu fileMenu = getMenuWithName("File");
    int itemCount = fileMenu.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        JMenuItem item = fileMenu.getItem(i);
        if ("exitMenuItem".equals(item.getName())) {
            // reset item to last item
            fileMenu.insert(item, itemCount);
        }
    }
}