How it works
The KeyLabel component registers a global listener for KeyEvents using:
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);On receiving KEY_RELEASED event formats the KeyStroke as a string and displays it. The dropdown shows history of last 100 keystrokes. Clicking on the X (Clear KeyStroke History) button clears the keystroke history. The KeyEvent listening can be suspended by deseleting the checkbox.
Usage
JComponent keyLabel = KeyLabelFactory.createKeyLabel();Demo
// Use keyLabel in your application's statusbar
Download (KeyLabel.jar)
> java -jar KeyLabel.jarScreenshot of KeyLabel Demo
Source Code
No comments:
Post a Comment