List of usage examples for javax.swing JMenu insert
public JMenuItem insert(Action a, int pos)
Action
object at a given position. 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); } } }