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:
MouseListener
KeyListener
withkeyMatcher
, can begetDefaultKeyMatcher()
ActionListener
caused bygetAction()
menuBuilder
determines menu items in the popup menu via
PopupExtension.PopupMenuBuilder.buildWithClear(PopupExtension.PopupMenuFilter, JPopupMenu)
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a default popup-menu factory creating a new popup and setting it to the componentstatic class
custom popup-menu for fixing display location issue: overriding setLocationstatic class
a menu-selector by incremental key-typingstatic class
improve default behavior of showing popup menu: clicking a menu button while the menu is visible can hide itstatic class
an action for displaying a popup menustatic interface
the interface for constructing menusstatic class
the empty builderstatic interface
the function interface for menu filteringstatic class
a filter for accepting any items as isstatic class
a window-listener and popup-menu listener for fixing the behavior of showing/hiding a popup menustatic class
the menu listener for callingsetupMenu()
static class
keyCode and modifierEx: ALT_DOWN_MASK, ... -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Action
protected PopupExtension.PopupCancelChecker
protected PopupExtension.PopupMenuFilter
protected Supplier
<JPopupMenu> the supplier is frequently called and expected to return same menu objectstatic String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
protected PopupExtension.PopupMenuBuilder
protected 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 asKeyListener
andMouseListener
PopupExtension
(JComponent pane, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder menuBuilder, JPopupMenu menu) PopupExtension
(JComponent pane, PopupExtension.PopupMenuBuilder menuBuilder) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addListenersTo
(JComponent pane) protected void
void
static KeyStroke
getKeyCode
(int keyCode, int modifiersEx) static KeyStroke
getKeyStroke
(int key, int... mask) getMenu()
static int
getPane()
void
void
void
void
void
void
void
Note: currently disabled using the mechanism, instead shown by framework original impl.void
void
void
setMenuBuilder
(PopupExtension.PopupMenuBuilder menuBuilder) protected void
void
void
void
void
-
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 asKeyListener
andMouseListener
- 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:
keyPressed
in interfaceKeyListener
-
showByKey
-
keyTyped
- Specified by:
keyTyped
in interfaceKeyListener
-
keyReleased
- Specified by:
keyReleased
in interfaceKeyListener
-
mousePressed
Note: currently disabled using the mechanism, instead shown by framework original impl. Some LAF relies on it.- Specified by:
mousePressed
in interfaceMouseListener
- Parameters:
e
- the handling event
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
getAction
-
show
-
show
-
setupMenu
public void setupMenu()
-