public class VirtualKeyboard extends javax.swing.JComponent implements KeyboardState
javax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
AUTO_SHOW_PROPERTY
Client property key specifying whether the virtual keyboard is automatically shown on focus.
|
static java.lang.String |
CUSTOM_LAYOUT_PROPERTY
Client property key specifying a custom keyboard layout template for a component.
|
static java.lang.String |
LAYOUT_MODE_PROPERTY
Client property key specifying the keyboard layout mode for a component.
|
static java.lang.String |
POPUP_PLACEMENT_PROPERTY
Client property key specifying the popup placement relative to a component.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
VirtualKeyboard()
Initializes a new instance of the VirtualKeyboard class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addVirtualKeyboardListener(VirtualKeyboardListener listener)
Registers listener so that it will receive events when users press keyboard keys.
|
void |
applyTheme(java.io.InputStream stream)
Applies a theme to the keyboard and its keys.
|
void |
applyTheme(java.lang.String fileName)
Applies a theme to the keyboard and its keys.
|
void |
dispose() |
static boolean |
getAltGrLocked()
Gets the state of the AltGr key.
|
static boolean |
getAltLocked()
Gets the state of the Alt key.
|
boolean |
getAutoFill()
Gets whether keyboard layout should be generated automatically depending
on the language (e.g.
|
boolean |
getAutoReleaseModifierKeys()
Gets whether pressing a regular key automatically releases modifier keys
such as shift, alt, control etc.
|
boolean |
getAutoRepeat()
Gets whether the component should synthesize keyboard events repeatedly when
a virtual key is pressed down, until the key is released.
|
static boolean |
getAutoShow(java.awt.Component c)
Gets whether automatic keyboard popup on focus is enabled for the specified component,
inheriting from parent containers or the top-level window if not set directly.
|
static boolean |
getCapsLocked()
Gets the state of the Caps-lock key.
|
static boolean |
getControlLocked()
Gets the state of the Control key.
|
KeyboardLayout |
getCurrentLayout()
Gets the current keyboard layout.
|
static KeyboardLayout |
getCustomLayout(java.awt.Component c)
Gets the custom keyboard layout template associated with the specified component,
inheriting from parent containers if not set directly.
|
KeyboardLayout |
getDefaultLayout()
Gets the default keyboard layout.
|
boolean |
getFollowSystemInputLanguage()
Gets a value indicating whether the keyboard automatically follows the system's input language.
|
java.util.Locale |
getInputLocale()
Gets the current input language.
|
KeyTemplate |
getKeyTemplate()
Gets the appearance of key buttons.
|
static KeyboardMode |
getLayoutMode(java.awt.Component c)
Gets the keyboard layout mode associated with the specified component,
inheriting from parent containers or the default if not set directly.
|
java.util.List<KeyboardLayout> |
getLayoutRing()
Gets a list of keyboard layouts that can be cycled through.
|
int |
getLayoutRingIndex()
Gets the index of the current layout in the LayoutRing.
|
java.lang.String |
getLayoutsFolder()
Gets the folder where layout files are located.
|
KeyboardMode |
getMode()
Gets the layout mode.
|
static boolean |
getNumLocked()
Gets the state of the Num-lock key.
|
boolean |
getPasswordMode()
Gets whether password mode is enabled.
|
static PopupPlacement |
getPopupPlacement(java.awt.Component c)
Gets the popup placement mode relative to the specified component,
inheriting from parent containers or the default if not set directly.
|
int |
getRepeatDelay()
Specifies the initial delay in milliseconds before the component
starts repeating key-down events when AutoRepeat is enabled.
|
boolean |
getRepeatDownOnly()
Gets whether keys repeat only key-down events, with a single key-up generated in the end.
|
int |
getRepeatRate()
Gets the delay in milliseconds between consecutive key-down events synthesized in AutoRepeat mode.
|
static boolean |
getScrollLocked()
Gets the state of the Scroll-lock key.
|
static boolean |
getShiftLocked()
Gets the state of the Shift key.
|
boolean |
getStandalone()
Gets whether the keyboard is the only content of the application's window.
|
Stretch |
getStretch()
Gets a stretch mode that determines how the keyboard
fits into the available space.
|
KeyboardLayout |
getTemplateLayout()
Gets the keyboard's layout template.
|
Theme |
getTheme()
Gets the keyboard appearance theme.
|
boolean |
getUseSystemKeyMapping()
Returns whether the virtual keyboard uses the operating system's
key-to-character mapping based on the current system keyboard layout.
|
static void |
hidePopup()
Hides the virtual keyboard popup if currently visible.
|
static void |
installAutoShow()
Installs automatic popup display globally across all windows.
|
static void |
installAutoShow(java.awt.Window window)
Installs automatic popup display on the specified window.
|
static boolean |
isInputControl(java.awt.Component c)
Determines whether the specified component is considered an editable input control.
|
static boolean |
isPopupVisible()
Returns whether the virtual keyboard popup is currently visible.
|
void |
loadImeTable(java.util.Locale locale,
java.lang.String filePath)
Loads an IME table file for specified locale.
|
void |
paintComponent(java.awt.Graphics graphics)
JComponent.paintComponent override.
|
void |
removeVirtualKeyboardListener(VirtualKeyboardListener listener)
Unregisters listener so that it will no longer receive keyboard events.
|
void |
selectLayout(int index)
Selects a layout from the layout ring at the specified index.
|
static void |
sendClear()
Sends a clear command (Ctrl+A followed by Backspace) to the focused control.
|
void |
sendKey(Key objKey)
Sends the specified key input to active window.
|
void |
setAutoFill(boolean value)
Sets whether keyboard layout should be generated automatically depending
on the language (e.g.
|
void |
setAutoReleaseModifierKeys(boolean value)
Sets whether pressing a regular key automatically releases modifier keys
such as shift, alt, control etc.
|
void |
setAutoRepeat(boolean value)
Sets whether the component should synthesize keyboard events repeatedly when
a virtual key is pressed down, until the key is released.
|
static void |
setAutoShow(java.awt.Component c,
boolean value)
Sets whether automatic keyboard popup on focus is enabled for the specified component.
|
static void |
setCustomLayout(java.awt.Component c,
KeyboardLayout value)
Sets a custom keyboard layout template for the specified component.
|
void |
setDefaultLayout(KeyboardLayout value)
Sets the default keyboard layout.
|
void |
setFollowSystemInputLanguage(boolean value)
Sets a value indicating whether the keyboard automatically follows the system's input language.
|
void |
setFont(java.awt.Font value)
JComponent.setFont override.
|
void |
setInputLocale(java.util.Locale value)
Sets the current input language.
|
void |
setKeyTemplate(KeyTemplate value)
Sets the appearance of key buttons.
|
static void |
setLayoutMode(java.awt.Component c,
KeyboardMode value)
Sets the keyboard layout mode associated with the specified component.
|
void |
setLayoutRing(java.util.List<KeyboardLayout> layouts)
Sets a list of keyboard layouts that can be cycled through.
|
void |
setLayoutsFolder(java.lang.String value)
Sets the folder where layout files are located.
|
static void |
setLicenseKey(java.lang.String licenseKey)
Sets the component's license key string, disabling evaluation mode.
|
void |
setMode(KeyboardMode value)
Sets the layout mode.
|
void |
setPasswordMode(boolean value)
Sets whether password mode is enabled.
|
static void |
setPopupPlacement(java.awt.Component c,
PopupPlacement value)
Sets the popup placement mode relative to the specified component.
|
void |
setRepeatDelay(int value)
Specifies the initial delay in milliseconds before the component
starts repeating key-down events when AutoRepeat is enabled.
|
void |
setRepeatDownOnly(boolean value)
Sets whether keys repeat only key-down events, with a single key-up generated in the end.
|
void |
setRepeatRate(int value)
Sets the delay in milliseconds between consecutive key-down events synthesized in AutoRepeat mode.
|
void |
setStandalone(boolean value)
Sets whether the keyboard is the only content of the application's window.
|
void |
setStretch(Stretch value)
Sets a stretch mode that determines how the keyboard
fits into the available space.
|
void |
setTemplateLayout(KeyboardLayout value)
Sets the keyboard's layout template.
|
void |
setTheme(Theme value)
Sets the keyboard appearance theme.
|
void |
setUseSystemKeyMapping(boolean value)
Sets whether the virtual keyboard should use the operating system's
key-to-character mapping based on the current system keyboard layout.
|
static void |
showPopup(java.awt.Component target)
Shows the virtual keyboard popup for the specified target component.
|
static void |
uninstallAutoShow()
Disables automatic popup display globally.
|
static void |
uninstallAutoShow(java.awt.Window window)
Disables automatic popup display for the specified window.
|
void |
unlockKeys()
Unlocks all modifier keys.
|
void |
updateLayoutRingKeyAppearance(LayoutRingKey layoutRingKey)
Updates the visual appearance of a layout ring key.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final java.lang.String AUTO_SHOW_PROPERTY
public static final java.lang.String LAYOUT_MODE_PROPERTY
public static final java.lang.String POPUP_PLACEMENT_PROPERTY
public static final java.lang.String CUSTOM_LAYOUT_PROPERTY
public VirtualKeyboard()
public void dispose()
public void setLayoutsFolder(java.lang.String value)
value - A String specifying the location of locale-specific layout files
used when KeyboardMode is set to Custom.public java.lang.String getLayoutsFolder()
public void setAutoFill(boolean value)
value - true to automatically fill regular character keys, or false otherwise.public boolean getAutoFill()
public void setTheme(Theme value)
value - A member of the Theme enumeration.public Theme getTheme()
Theme enumeration.public void setKeyTemplate(KeyTemplate value)
value - An instance of the KeyTemplate class.public KeyTemplate getKeyTemplate()
KeyTemplate class.public void setAutoReleaseModifierKeys(boolean value)
value - true to release modifiers automatically, or false otherwise.public boolean getAutoReleaseModifierKeys()
public void setDefaultLayout(KeyboardLayout value)
value - An instance of the KeyboardLayout class.public KeyboardLayout getDefaultLayout()
KeyboardLayout class.public void setTemplateLayout(KeyboardLayout value)
value - An instance of the KeyboardLayout class.public KeyboardLayout getTemplateLayout()
KeyboardLayout class.public void setMode(KeyboardMode value)
value - A member of the KeyboardMode enumeration.public KeyboardMode getMode()
KeyboardMode enumeration.public void setStandalone(boolean value)
value - true if the application acts only as virtual keyboard,
or false if used as embedded keyboard.public boolean getStandalone()
public void setInputLocale(java.util.Locale value)
value - An instance of the java.util.Locale class.public java.util.Locale getInputLocale()
public void unlockKeys()
public void setFont(java.awt.Font value)
setFont in class javax.swing.JComponentpublic void applyTheme(java.io.InputStream stream)
stream - A Stream from which to load theme attributes.public void applyTheme(java.lang.String fileName)
fileName - The file from which to load theme attributes.public void paintComponent(java.awt.Graphics graphics)
paintComponent in class javax.swing.JComponentpublic static void setLicenseKey(java.lang.String licenseKey)
licenseKey - A string value containing encoded license information.public void sendKey(Key objKey)
objKey - An instance of Key -derived class.public void loadImeTable(java.util.Locale locale,
java.lang.String filePath)
locale - java.util.Locale instance specifying the locale.filePath - Path to the dictionary file or folder.public static boolean getShiftLocked()
public static boolean getControlLocked()
public static boolean getAltLocked()
public static boolean getAltGrLocked()
public static boolean getNumLocked()
public static boolean getScrollLocked()
public static boolean getCapsLocked()
public static void sendClear()
public java.util.List<KeyboardLayout> getLayoutRing()
getLayoutRing in interface KeyboardStateKeyboardLayout objects.public void setLayoutRing(java.util.List<KeyboardLayout> layouts)
layouts - A List of KeyboardLayout objects.public int getLayoutRingIndex()
getLayoutRingIndex in interface KeyboardStatepublic KeyboardLayout getCurrentLayout()
getCurrentLayout in interface KeyboardStateKeyboardLayout.public void updateLayoutRingKeyAppearance(LayoutRingKey layoutRingKey)
updateLayoutRingKeyAppearance in interface KeyboardStatelayoutRingKey - The key to update.public void selectLayout(int index)
index - The index of the layout to select.public void addVirtualKeyboardListener(VirtualKeyboardListener listener)
listener - An object implementing the VirtualKeyboardListener interface.public void removeVirtualKeyboardListener(VirtualKeyboardListener listener)
listener - An object implementing the VirtualKeyboardListener interface.public boolean getAutoRepeat()
public void setAutoRepeat(boolean value)
value - true to enable automatic repeat, or false otherwise. The default value is true.public int getRepeatDelay()
public void setRepeatDelay(int value)
value - An integer value specifying initial delay in milliseconds. The default value is 500.public int getRepeatRate()
public void setRepeatRate(int value)
value - An integer value specifying delay in milliseconds. The default value is 20.public boolean getRepeatDownOnly()
public void setRepeatDownOnly(boolean value)
value - true if repeating only key-down events, or false if repeating down/up events in pairs.public Stretch getStretch()
Stretch enumeration.public void setStretch(Stretch value)
value - A member of the Stretch enumeration.public boolean getFollowSystemInputLanguage()
public void setFollowSystemInputLanguage(boolean value)
value - true to follow the system input language, or false otherwise.public boolean getUseSystemKeyMapping()
When true, key events are translated using the OS-provided layout (including language-specific mappings). When false, the virtual keyboard uses its own internal key-to-character mapping and ignores the system layout.
public void setUseSystemKeyMapping(boolean value)
Set this to true to let the keyboard follow the OS layout and language. Set to false to force the keyboard to use its own internal key-to-character mapping, ignoring the system's layout.
value - true to use the OS key mapping, or false to use the keyboard's custom mappingpublic boolean getPasswordMode()
public void setPasswordMode(boolean value)
value - true to enable password mode, or false otherwise.public static void setAutoShow(java.awt.Component c,
boolean value)
c - The component to configure.value - true to enable auto-show, or false to disable.public static boolean getAutoShow(java.awt.Component c)
c - The component to inspect.public static void setLayoutMode(java.awt.Component c,
KeyboardMode value)
c - The component to configure.value - The keyboard layout mode.public static KeyboardMode getLayoutMode(java.awt.Component c)
c - The component to inspect.public static void setPopupPlacement(java.awt.Component c,
PopupPlacement value)
c - The component to configure.value - The popup placement mode.public static PopupPlacement getPopupPlacement(java.awt.Component c)
c - The component to inspect.public static void setCustomLayout(java.awt.Component c,
KeyboardLayout value)
c - The component to configure.value - The custom keyboard layout template.public static KeyboardLayout getCustomLayout(java.awt.Component c)
c - The component to inspect.public static boolean isInputControl(java.awt.Component c)
c - The component to inspect.public static void installAutoShow()
public static void installAutoShow(java.awt.Window window)
window - The window to enable auto-show for.public static void uninstallAutoShow()
public static void uninstallAutoShow(java.awt.Window window)
window - The window to disable auto-show for.public static void showPopup(java.awt.Component target)
target - The target input component.public static void hidePopup()
public static boolean isPopupVisible()