QwertyPanel (version 7) is a standalone Class offering basic keyboard-style entry from a gridbag of onscreen clickable buttons. All numbers and letters are present. Letters are upper-case only. Enter, dot, hyphen, space and backspace are also available. There is a method to re-label any of the four 'soft' Fkeys in the top row. They default to F1 thru F4; if they are re-labeled as "" they are automatically disabled.
At the top left there is a button that switches between qwerty and alphabetic layout. There are also methods to enable/disable a single key or all keys, to add and remove ActionListeners, to switch between layouts and to interrogate which layout is being used and whether a particular key is enabled. The colors used for enabled and disabled buttons can be set in the overloaded constructor (and are set as public in case you want to change these after instantiation). This is achieved by subclassing Button as MyButton, adding relevant functionality to its constructor and overriding the inherited setEnabled() method to embrace a background color before calling the superclass.
Hopefully, all this should make it practical to instantiate a QwertyPanel as a tool for (predictable/specifiable) user input in GUI environments.
ActionCommands passed are the strings that appear on the face of the buttons.
|
Constructors:
|
QwertyPanel()
QwertyPanel(int LAYOUT_TYPE), QwertyPanel(int LAYOUT_TYPE, Color enabledColor, Color disabledColor) |
|
Public methods:
|
void setFkey(int number, String label)
void setKeyEnabled(String label, boolean state) void enableAllKeys() void disableAllKeys() boolean isKeyEnabled(String label) boolean isQwertyLayout() void setLayout(int LAYOUT_TYPE) void addActionListener(ActionListener l) void removeActionListener(ActionListener l) |
The previous version used two panels (one for each key layout) treated as a CardLayout. This revised version uses one panel only and re-labels buttons to achieve different key layouts. I found it more difficult in terms of logic and data management, especially concerning keeping a record of which keys are dis/enabled, but it is faster and neater and was an interesting challenge.
Source code for class QwertyPanel
Launch a test QwertyPanel demo applet where I've added a couple of buttons and a text field to control/report on the QwertyPanel. I've set this demo so that a key gets disabled once it has been clicked.
Andy Murray 23/11/02