java.lang.Object
org.autogui.swing.util.PopupExtension
- All Implemented Interfaces:
ActionListener,KeyListener,MouseListener,EventListener
- Direct Known Subclasses:
GuiSwingViewCollectionTable.PopupExtensionCollection,GuiSwingViewCollectionTable.PopupExtensionCollectionColumnHeader,PopupExtensionText
a popup menu manager.
it supports showing the popup menu supplied by
menu via the following event listeners:
MouseListenerKeyListenerwithkeyMatcher, can begetDefaultKeyMatcher()ActionListenercaused bygetAction()
menuBuilder determines menu items in the popup menu via
PopupExtension.PopupMenuBuilder.buildWithClear(PopupExtension.PopupMenuFilter, JPopupMenu).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classa default popup-menu factory creating a new popup and setting it to the componentstatic classcustom popup-menu for fixing display location issue: overriding setLocationstatic classa menu-selector by incremental key-typingstatic classimprove default behavior of showing popup menu: clicking a menu button while the menu is visible can hide itstatic classan action for displaying a popup menustatic interfacethe interface for constructing menusstatic classthe empty builderstatic interfacethe function interface for menu filteringstatic classa filter for accepting any items as isstatic classa window-listener and popup-menu listener for fixing the behavior of showing/hiding a popup menustatic classthe menu listener for callingsetupMenu()static classkeyCode and modifierEx: ALT_DOWN_MASK, ... -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Actionprotected PopupExtension.PopupCancelCheckerprotected PopupExtension.PopupMenuFilterprotected Supplier<JPopupMenu> the supplier is frequently called and expected to return same menu objectstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringprotected PopupExtension.PopupMenuBuilderprotected JComponent -
Constructor Summary
ConstructorsConstructorDescriptionPopupExtension(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder) PopupExtension(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder, Supplier<JPopupMenu> menu) add this to pane asKeyListenerandMouseListenerPopupExtension(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder, JPopupMenu menu) PopupExtension(JComponent pane, PopupExtension.PopupMenuBuilder menuBuilder) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddListenersTo(JComponent pane) protected voidvoidstatic KeyStrokegetKeyCode(int keyCode, int modifiersEx) static KeyStrokegetKeyStroke(int key, int... mask) getMenu()static intgetPane()voidvoidvoidvoidvoidvoidvoidNote: currently disabled using the mechanism, instead shown by framework original impl.voidvoidvoidsetMenuBuilder(PopupExtension.PopupMenuBuilder menuBuilder) protected voidvoidvoidvoidvoid
-
Field Details
-
MENU_CATEGORY_UNDO
-
MENU_CATEGORY_EDIT
-
MENU_CATEGORY_SET
-
MENU_CATEGORY_JUMP
-
MENU_CATEGORY_SELECT
-
MENU_CATEGORY_TRANSFER
-
MENU_CATEGORY_VIEW
-
MENU_CATEGORY_PREFS
-
MENU_CATEGORY_WINDOW
-
MENU_SUB_CATEGORY_NEW
-
MENU_SUB_CATEGORY_UNDO
-
MENU_SUB_CATEGORY_REDO
-
MENU_SUB_CATEGORY_CUT
-
MENU_SUB_CATEGORY_COPY
-
MENU_SUB_CATEGORY_PASTE
-
MENU_SUB_CATEGORY_DELETE
-
MENU_SUB_CATEGORY_SELECT
-
MENU_SUB_CATEGORY_IMPORT
-
MENU_SUB_CATEGORY_EXPORT
-
MENU_SUB_CATEGORY_PREFS_CHANGE
-
MENU_SUB_CATEGORY_PREFS_WINDOW
-
MENU_SUB_CATEGORY_WINDOW_VIEW
-
MENU_SUB_CATEGORY_WINDOW_SELECT
-
filter
-
pane
-
keyMatcher
-
cancelChecker
-
action
-
MENU_FILTER_IDENTITY
-
-
Constructor Details
-
PopupExtension
public PopupExtension(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder, JPopupMenu menu) - Parameters:
pane- the host pane of the popup-menu, can be nullkeyMatcher- matching with a key-event for displaying the menumenuBuilder- a builder for constructing menu-itemsmenu- the displayed popup-menu, can be null
-
PopupExtension
public PopupExtension(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder, Supplier<JPopupMenu> menu) add this to pane asKeyListenerandMouseListener- Parameters:
pane- the host pane of the popup-menu, can be nullkeyMatcher- matching with a key-event for displaying the menumenuBuilder- a builder for constructing menu-itemsmenu- the supplier of the displayed popup-menu
-
PopupExtension
public PopupExtension(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder) callPopupExtension(JComponent, Predicate, PopupMenuBuilder, Supplier). the menu is supplied by creating a new one and setting it byJComponent.setComponentPopupMenu(JPopupMenu). it also callsPopupExtension.MenuKeySelector.addToMenu(JPopupMenu)for incremental item search while showing the popup menu- Parameters:
pane- the host pane of the popup-menu, can be nullkeyMatcher- matching with a key-event for displaying the menumenuBuilder- a builder for constructing menu-items
-
PopupExtension
- Parameters:
pane- the host pane of the popup-menu, can be nullmenuBuilder- a builder for constructing menu-items
-
-
Method Details
-
setFilter
-
getFilter
-
setupCancelChecker
protected void setupCancelChecker() -
addListenersToPane
public void addListenersToPane() -
addListenersTo
-
addListenersToAsPopupMenuListener
- Parameters:
pane- the target pane- Since:
- 1.3
-
getDefaultKeyMatcher
-
getDefaultKeyStroke
-
getKeyStroke
-
getMenuShortcutKeyMask
public static int getMenuShortcutKeyMask() -
getKeyCode
- Parameters:
keyCode- a key code such as KeyEvent.VK_SPACEmodifiersEx- extended modifiers such as KeyEvent.CTRL_DOWN_MASK, or 0- Returns:
- a predicate matching with the parameters
-
getKeyMatcher
-
getMenu
-
getMenuBuilder
-
setMenuBuilder
-
getPane
-
keyPressed
- Specified by:
keyPressedin interfaceKeyListener
-
showByKey
-
keyTyped
- Specified by:
keyTypedin interfaceKeyListener
-
keyReleased
- Specified by:
keyReleasedin interfaceKeyListener
-
mousePressed
Note: currently disabled using the mechanism, instead shown by framework original impl. Some LAF relies on it.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
e- the handling event
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
getAction
-
show
-
show
-
setupMenu
public void setupMenu()
-