Package org.omegat.util.gui
Class MenuItemPager
java.lang.Object
org.omegat.util.gui.MenuItemPager
A helper class for creating nested submenus. Usage:
- In the constructor provide the target menu to which you want to add items.
- Optionally set the number of items per page with
setItemsPerPage(int)(default isDEFAULT_ITEMS_PER_PAGE). - Call
add(JMenuItem)for each item to add. A new submenu will be created and automatically added to the current (sub)menu as necessary. - Optionally obtain the "first page" of items (the items added directly to the root target menu) with
getFirstPage().
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMenuItemPager(JMenu menu) MenuItemPager(JPopupMenu menu) MenuItemPager(MenuExtender.MenuKey target) -
Method Summary
Modifier and TypeMethodDescriptionAdd an item to the menu.Get the "first page" of items (the items added directly to the provided root menu).voidsetItemsPerPage(int itemsPerPage) Set the size of the page (number of items allowed before a new submenu is created).
-
Field Details
-
DEFAULT_ITEMS_PER_PAGE
public static final int DEFAULT_ITEMS_PER_PAGE- See Also:
-
-
Constructor Details
-
MenuItemPager
-
MenuItemPager
-
MenuItemPager
-
-
Method Details
-
setItemsPerPage
public void setItemsPerPage(int itemsPerPage) Set the size of the page (number of items allowed before a new submenu is created). The actual number of items added to any (sub)menu isitemsPerPage + 1for the next submenu.- Parameters:
itemsPerPage- Page size
-
add
Add an item to the menu. The item will be added to a submenu as appropriate.- Parameters:
newItem- The item to add- Returns:
- The provided item
-
getFirstPage
Get the "first page" of items (the items added directly to the provided root menu). If a second page was added, the list will include the item representing the submenu.- Returns:
- The first-page items
-