|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.alee.managers.hotkey.HotkeyManager
public final class HotkeyManager
This manager allows you to quickly register global hotkeys (like accelerators on menu items in menubar menus) for any Swing component. Additionally you can specify a component which will limit hotkey events to its area (meaning that hotkey event will occur only if this component or any of its childs is focused when hotkey pressed).
TooltipManager is integrated with this manager to automatically show component hotkeys in its tooltip if needed/allowed by tooltip and hotkey settings. All hotkeys are stored into WeakHashMap so hotkeys will be removed as soon as the component for which hotkey is registered gets finalized. HotkeyInfo also keeps a weak reference to both top and hotkey components.
Field Summary | |
---|---|
protected static java.util.Map<java.awt.Container,java.util.List<HotkeyCondition>> |
containerConditions
Conditions for top components which might. |
protected static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> |
hotkeys
Added hotkeys. |
protected static boolean |
hotkeysEnabled
Global hotkeys block flag. |
protected static boolean |
initialized
Initialization mark. |
protected static java.lang.Object |
sync
Synchronization object. |
protected static boolean |
transferFocus
Pass focus to fired hotkey component. |
Constructor Summary | |
---|---|
HotkeyManager()
|
Method Summary | |
---|---|
static void |
addContainerHotkeyCondition(java.awt.Container container,
HotkeyCondition hotkeyCondition)
Sets top component additional hotkey trigger condition |
protected static void |
cacheHotkey(HotkeyInfo hotkeyInfo)
Hotkeys cache methods |
protected static void |
clearHotkeyCache(HotkeyInfo hotkeyInfo)
|
protected static void |
clearHotkeysCache(java.awt.Component component)
|
protected static void |
clearHotkeysCache(java.util.List<HotkeyInfo> hotkeys)
|
protected static java.util.Map<java.awt.Container,java.util.List<HotkeyCondition>> |
copyContainerConditions()
|
protected static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> |
copyHotkeys()
Returns a full copy of hotkeys map. |
protected static HotkeyRunnable |
createAction(javax.swing.AbstractButton forComponent)
|
static void |
disableHotkeys()
Global hotkey block |
static void |
enableHotkeys()
|
static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> |
getAllHotkeys()
All added hotkeys. |
static java.util.List<HotkeyInfo> |
getComponentHotkeys(java.awt.Component component)
Hotkeys retrieval methods |
protected static java.util.List<HotkeyInfo> |
getComponentHotkeysCache(java.awt.Component component)
|
static java.lang.String |
getComponentHotkeysString(java.awt.Component component)
All component hotkeys list |
protected static java.lang.String |
getComponentHotkeysString(java.util.List<HotkeyInfo> infoList)
|
static java.util.List<HotkeyCondition> |
getContainerHotkeyConditions(java.awt.Container container)
|
protected static java.util.List<HotkeyCondition> |
getContainerHotkeyConditionsCache(java.awt.Container container)
|
protected static boolean |
hotkeyForEventExists(java.awt.event.KeyEvent keyEvent)
Returns whether at least one hotkey for the specified key event exists or not. |
static void |
initialize()
Initializes hotkey manager. |
static void |
installShowAllHotkeysAction(java.awt.Component topComponent)
Installs "show all hotkeys" action on window or component |
static void |
installShowAllHotkeysAction(java.awt.Component topComponent,
HotkeyData hotkeyData)
|
static boolean |
isTransferFocus()
Should transfer focus to fired hotkey component or not |
protected static boolean |
meetsParentConditions(java.awt.Component forComponent)
|
protected static void |
processHotkeys(java.awt.event.KeyEvent e)
Processes all available registered hotkeys. |
static HotkeyInfo |
registerHotkey(javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData)
Button-specific hotkey register methods |
static HotkeyInfo |
registerHotkey(javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
javax.swing.AbstractButton forComponent,
HotkeyData hotkeyData,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
java.awt.Component forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
java.awt.Component forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
java.awt.Component forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
boolean hidden,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component topComponent,
java.awt.Component forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
TooltipWay tooltipWay)
|
static HotkeyInfo |
registerHotkey(java.awt.Component forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action)
|
static HotkeyInfo |
registerHotkey(java.awt.Component forComponent,
HotkeyData hotkeyData,
HotkeyRunnable action,
boolean hidden)
|
static HotkeyInfo |
registerHotkey(HotkeyData hotkeyData,
HotkeyRunnable action)
Hotkey register methods |
static void |
removeContainerHotkeyCondition(java.awt.Container container,
HotkeyCondition hotkeyCondition)
|
static void |
removeContainerHotkeyConditions(java.awt.Container container)
|
static void |
setComponentHotkeyDisplayWay(java.awt.Component component,
TooltipWay tooltipWay)
Sets component hotkey tip way |
static void |
setTransferFocus(boolean transferFocus)
|
static void |
showComponentHotkeys()
Shows all visible components hotkeys |
static void |
showComponentHotkeys(java.awt.Component component)
|
protected static void |
showComponentHotkeys(java.awt.Window window)
|
static void |
unregisterHotkey(HotkeyInfo hotkeyInfo)
Hotkey removal methods |
static void |
unregisterHotkeys(java.awt.Component component)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.Object sync
protected static boolean hotkeysEnabled
protected static boolean transferFocus
protected static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> hotkeys
protected static java.util.Map<java.awt.Container,java.util.List<HotkeyCondition>> containerConditions
protected static boolean initialized
Constructor Detail |
---|
public HotkeyManager()
Method Detail |
---|
public static void initialize()
protected static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> copyHotkeys()
protected static java.util.Map<java.awt.Container,java.util.List<HotkeyCondition>> copyContainerConditions()
protected static boolean hotkeyForEventExists(java.awt.event.KeyEvent keyEvent)
keyEvent
- key event to search hotkeys for
protected static void processHotkeys(java.awt.event.KeyEvent e)
e
- key eventprotected static boolean meetsParentConditions(java.awt.Component forComponent)
public static HotkeyInfo registerHotkey(HotkeyData hotkeyData, HotkeyRunnable action)
public static HotkeyInfo registerHotkey(java.awt.Component forComponent, HotkeyData hotkeyData, HotkeyRunnable action)
public static HotkeyInfo registerHotkey(java.awt.Component forComponent, HotkeyData hotkeyData, HotkeyRunnable action, boolean hidden)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, java.awt.Component forComponent, HotkeyData hotkeyData, HotkeyRunnable action)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, java.awt.Component forComponent, HotkeyData hotkeyData, HotkeyRunnable action, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, java.awt.Component forComponent, HotkeyData hotkeyData, HotkeyRunnable action, boolean hidden)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, java.awt.Component forComponent, HotkeyData hotkeyData, HotkeyRunnable action, boolean hidden, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(javax.swing.AbstractButton forComponent, HotkeyData hotkeyData)
public static HotkeyInfo registerHotkey(javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, boolean hidden)
public static HotkeyInfo registerHotkey(javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.AbstractButton forComponent, HotkeyData hotkeyData)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, TooltipWay tooltipWay)
public static HotkeyInfo registerHotkey(java.awt.Component topComponent, javax.swing.AbstractButton forComponent, HotkeyData hotkeyData, boolean hidden)
protected static HotkeyRunnable createAction(javax.swing.AbstractButton forComponent)
public static void setComponentHotkeyDisplayWay(java.awt.Component component, TooltipWay tooltipWay)
public static void addContainerHotkeyCondition(java.awt.Container container, HotkeyCondition hotkeyCondition)
public static void removeContainerHotkeyCondition(java.awt.Container container, HotkeyCondition hotkeyCondition)
public static void removeContainerHotkeyConditions(java.awt.Container container)
public static java.util.List<HotkeyCondition> getContainerHotkeyConditions(java.awt.Container container)
protected static java.util.List<HotkeyCondition> getContainerHotkeyConditionsCache(java.awt.Container container)
public static void unregisterHotkey(HotkeyInfo hotkeyInfo)
public static void unregisterHotkeys(java.awt.Component component)
public static java.util.List<HotkeyInfo> getComponentHotkeys(java.awt.Component component)
public static java.util.Map<java.awt.Component,java.util.List<HotkeyInfo>> getAllHotkeys()
protected static void cacheHotkey(HotkeyInfo hotkeyInfo)
protected static void clearHotkeyCache(HotkeyInfo hotkeyInfo)
protected static void clearHotkeysCache(java.util.List<HotkeyInfo> hotkeys)
protected static void clearHotkeysCache(java.awt.Component component)
protected static java.util.List<HotkeyInfo> getComponentHotkeysCache(java.awt.Component component)
public static void showComponentHotkeys()
public static void showComponentHotkeys(java.awt.Component component)
protected static void showComponentHotkeys(java.awt.Window window)
public static void installShowAllHotkeysAction(java.awt.Component topComponent)
public static void installShowAllHotkeysAction(java.awt.Component topComponent, HotkeyData hotkeyData)
public static java.lang.String getComponentHotkeysString(java.awt.Component component)
protected static java.lang.String getComponentHotkeysString(java.util.List<HotkeyInfo> infoList)
public static void disableHotkeys()
public static void enableHotkeys()
public static boolean isTransferFocus()
public static void setTransferFocus(boolean transferFocus)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |