com.sun.lwuit
Class VirtualKeyboard

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.Container
          extended by com.sun.lwuit.Form
              extended by com.sun.lwuit.Dialog
                  extended by com.sun.lwuit.VirtualKeyboard
All Implemented Interfaces:
Animation, StyleListener, VirtualKeyboardInterface

public class VirtualKeyboard
extends Dialog
implements VirtualKeyboardInterface

This class represent the LWUIT Light Weight Virtual Keyboard


Field Summary
static int CHANGE_MODE
           
static java.lang.String[][] DEFAULT_NUMBERS
          This keymap represents numbers keyboard
static java.lang.String[][] DEFAULT_NUMBERS_SYMBOLS
          This keymap represents numbers and symbols keyboard
static java.lang.String[][] DEFAULT_QWERTY
          This keymap represents qwerty keyboard
static java.lang.String[][] DEFAULT_SYMBOLS
          This keymap represents symbols keyboard
static int DELETE_CHAR
           
static int INSERT_CHAR
           
static java.lang.String NAME
           
static java.lang.String NUMBERS_MODE
          The String that represent the numbers mode.
static java.lang.String NUMBERS_SYMBOLS_MODE
          The String that represent the numbers sybols mode.
static int OK
           
static java.lang.String QWERTY_MODE
          The String that represent the qwerty mode.
static int SHIFT
           
static int SPACE
           
static java.lang.String SYMBOLS_MODE
          The String that represent the symbols mode.
static int T9
           
 
Fields inherited from class com.sun.lwuit.Dialog
TYPE_ALARM, TYPE_CONFIRMATION, TYPE_ERROR, TYPE_INFO, TYPE_NONE, TYPE_WARNING
 
Fields inherited from class com.sun.lwuit.Form
focusScrolling
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
VirtualKeyboard()
          Creates a new instance of VirtualKeyboard
 
Method Summary
protected  void actionCommand(Command cmd)
          Invoked to allow subclasses of form to handle a command from one point rather than implementing many command instances
static void addDefaultInputMode(java.lang.String mode, java.lang.String[][] inputChars)
          Add an input mode to the virtual keyboard
 void addInputMode(java.lang.String mode, java.lang.String[][] inputChars)
          Add an input mode to the virtual keyboard
 void addSpecialButton(java.lang.String key, Command cmd)
          This method adds a special button to the virtual keyboard
 void addSpecialButton(java.lang.String key, Command cmd, int space)
          This method adds a special button to the virtual keyboard
protected  void autoAdjust(int w, int h)
          Auto adjust size of the dialog.
static void bindVirtualKeyboard(TextArea t, VirtualKeyboard vkb)
          This method is used to bind a specific instance of a virtual keyboard to a specific TextField.
 void dispose()
          Closes the current form and returns to the previous form, releasing the EDT in the process
protected  java.lang.String getCurrentMode()
          Gets the current mode.
static java.lang.String[] getDefaultInputModeOrder()
          Returns the order in which input modes are toggled by default
protected  TextField getInputField()
          This method returns the Virtual Keyboard TextField.
 java.lang.String[] getInputModeOrder()
          Returns the order in which input modes are toggled
static Transition getTransitionIn()
          The transition in for the VKB
static Transition getTransitionOut()
          The transition out for the VKB
static VirtualKeyboard getVirtualKeyboard(TextArea t)
          This method returns the Textfield associated VirtualKeyboard, see bindVirtualKeyboard(TextField tf, VirtualKeyboard vkb) method.
 java.lang.String getVirtualKeyboardName()
          Returns the Virtual Keyboard name.
static int getVKBTint(TextArea tf)
          The tint color for the virtual keyboard when shown on top of this text field see the form tint methods for more information
protected  void initModes()
          init all virtual keyboard modes, such as QWERTY_MODE, NUMBERS_SYMBOLS_MODE...
protected  void initSpecialButtons()
          This method initialize all the virtual keyboard special buttons.
static boolean isCommitOnDispose(TextArea tf)
          Indicates whether the given text field should commit on dispose
static boolean isShowTooltips()
          Indicates whether tooltips should be shown when the keys in the VKB are pressed
 boolean isVirtualKeyboardShowing()
          Indicates if the Virtual Keyboard is currently showing.
protected  void onShow()
          Allows subclasses to bind functionality that occurs when a specific form or dialog appears on the screen
 void pointerDragged(int x, int y)
          If this Component is focused, the pointer dragged event will call this method
 void pointerPressed(int x, int y)
          If this Component is focused, the pointer pressed event will call this method
 void pointerReleased(int x, int y)
          If this Component is focused, the pointer released event will call this method
static void setCommitOnDispose(TextField tf, boolean b)
          Indicates whether the VKB should commit changes to the text field when the VKB is closed not via the OK button.
protected  void setCurrentMode(java.lang.String mode)
          Sets the current virtual keyboard mode.
static void setDefaultInputModeOrder(java.lang.String[] order)
          Sets the order in which input modes are toggled by default and allows disabling/hiding an input mode
static void setDefaultVirtualKeyboardClass(java.lang.Class vkbClazz)
          Sets the default virtual keyboard class for the com.sun.lwuit.VirtualKeyboard type This class is used as the default virtual keyboard class if the current platform VirtualKeyboard is com.sun.lwuit.VirtualKeyboard.
 void setInputModeOrder(java.lang.String[] order)
          Sets the order in which input modes are toggled and allows disabling/hiding an input mode
 void setInputType(int inputType)
          This can be used to indicate to the VirtualKeyboard what type of input to display.
static void setShowTooltips(boolean aShowTooltips)
          Indicates whether tooltips should be shown when the keys in the VKB are pressed
 void setTextField(TextArea field)
          Invoked internally by the implementation to indicate the text field that will be edited by the virtual keyboard
static void setTransitionIn(Transition aTransitionIn)
          The transition in for the VKB
static void setTransitionOut(Transition aTransitionOut)
          The transition out for the VKB
static void setVKBTint(TextField tf, int tint)
          Sets the tint color for the virtual keyboard when shown on top of this text field see the form tint methods for more information
 void show()
          The default version of show modal shows the dialog occupying the center portion of the screen.
 void showKeyboard(boolean show)
          Shows the virtual keyboard that is assoiciated with the displayed TextField or displays the default virtual keyboard.
 
Methods inherited from class com.sun.lwuit.Dialog
addComponent, addComponent, addComponent, addComponent, animate, getContentPane, getDefaultDialogPosition, getDefaultDialogType, getDialogComponent, getDialogPosition, getDialogStyle, getDialogType, getDialogUIID, getLayout, getTitle, getTitleComponent, getTitleStyle, isAutoDispose, isCommandsAsButtons, isDialogTitleCompatibilityMode, isDisableStaticDialogScrolling, isDisposeWhenPointerOutOfBounds, keyReleased, placeButtonCommands, removeAll, removeComponent, setAutoAdjustDialogSize, setAutoDispose, setCommandsAsButtons, setDefaultDialogPosition, setDefaultDialogType, setDialogPosition, setDialogStyle, setDialogTitleCompatibilityMode, setDialogType, setDialogUIID, setDisableStaticDialogScrolling, setDisposeWhenPointerOutOfBounds, setLayout, setScrollable, setTimeout, setTitle, setTitleComponent, setTitleComponent, show, show, show, show, show, show, show, show, show, show, show, show, show, show, showBack, showDialog, showModeless, showPacked, showPopupDialog
 
Methods inherited from class com.sun.lwuit.Form
addCommand, addCommand, addCommandListener, addGameKeyListener, addKeyListener, addOrientationListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addShowListener, deregisterAnimated, dispatchCommand, findNextFocusHorizontal, findNextFocusVertical, getBackCommand, getClearCommand, getCommand, getCommandCount, getComponentForm, getComponentIndex, getDefaultCommand, getFocused, getGlassPane, getMenuBar, getMenuStyle, getScrollAnimationSpeed, getSoftButton, getSoftButtonCount, getTintColor, getTitleArea, getTransitionInAnimator, getTransitionOutAnimator, hasMedia, hideNotify, isAlwaysTensile, isCyclicFocus, isFocusScrolling, isSingleFocusMode, isSmoothScrolling, keyPressed, keyRepeated, longKeyPress, longPointerPress, onShowCompleted, paint, paintBackground, paramString, pointerHover, pointerHoverPressed, pointerHoverReleased, refreshTheme, registerAnimated, removeAllCommands, removeCommand, removeCommandListener, removeGameKeyListener, removeKeyListener, removeOrientationListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeShowListener, replace, replaceAndWait, scrollComponentToVisible, setAlwaysTensile, setBackCommand, setBgImage, setClearCommand, setCyclicFocus, setDefaultCommand, setFocused, setFocusScrolling, setGlassPane, setMenuBar, setMenuCellRenderer, setMenuTransitions, setRTL, setScrollableX, setScrollableY, setScrollAnimationSpeed, setSmoothScrolling, setTintColor, setTitleStyle, setTransitionInAnimator, setTransitionOutAnimator, setVisible, showNotify, sizeChanged
 
Methods inherited from class com.sun.lwuit.Container
animateLayout, animateLayoutAndWait, applyRTL, calcPreferredSize, contains, dragInitiated, drop, findFirstFocusable, flushReplace, getBottomGap, getComponentAt, getComponentAt, getComponentCount, getGridPosX, getGridPosY, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled, isScrollableX, isScrollableY, layoutContainer, paintGlass, replace, replaceAndWait, replaceAndWait, revalidate, setCellRenderer, setEnabled, setLeadComponent, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getDirtyRegion, getDisabledStyle, getDragImage, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypes, getPropertyValue, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, handlesInput, hasFocus, initComponent, initCustomStyle, installDefaultPainter, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, laidOut, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerPressed, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setWidth, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_QWERTY

public static final java.lang.String[][] DEFAULT_QWERTY
This keymap represents qwerty keyboard


DEFAULT_NUMBERS

public static final java.lang.String[][] DEFAULT_NUMBERS
This keymap represents numbers keyboard


DEFAULT_NUMBERS_SYMBOLS

public static final java.lang.String[][] DEFAULT_NUMBERS_SYMBOLS
This keymap represents numbers and symbols keyboard


DEFAULT_SYMBOLS

public static final java.lang.String[][] DEFAULT_SYMBOLS
This keymap represents symbols keyboard


QWERTY_MODE

public static final java.lang.String QWERTY_MODE
The String that represent the qwerty mode.

See Also:
Constant Field Values

NUMBERS_MODE

public static final java.lang.String NUMBERS_MODE
The String that represent the numbers mode.

See Also:
Constant Field Values

NUMBERS_SYMBOLS_MODE

public static final java.lang.String NUMBERS_SYMBOLS_MODE
The String that represent the numbers sybols mode.

See Also:
Constant Field Values

SYMBOLS_MODE

public static final java.lang.String SYMBOLS_MODE
The String that represent the symbols mode.

See Also:
Constant Field Values

INSERT_CHAR

public static final int INSERT_CHAR
See Also:
Constant Field Values

DELETE_CHAR

public static final int DELETE_CHAR
See Also:
Constant Field Values

CHANGE_MODE

public static final int CHANGE_MODE
See Also:
Constant Field Values

SHIFT

public static final int SHIFT
See Also:
Constant Field Values

OK

public static final int OK
See Also:
Constant Field Values

SPACE

public static final int SPACE
See Also:
Constant Field Values

T9

public static final int T9
See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values
Constructor Detail

VirtualKeyboard

public VirtualKeyboard()
Creates a new instance of VirtualKeyboard

Method Detail

setInputType

public void setInputType(int inputType)
Description copied from interface: VirtualKeyboardInterface
This can be used to indicate to the VirtualKeyboard what type of input to display.

Specified by:
setInputType in interface VirtualKeyboardInterface

setTextField

public void setTextField(TextArea field)
Invoked internally by the implementation to indicate the text field that will be edited by the virtual keyboard

Parameters:
field - the text field instance

show

public void show()
Description copied from class: Dialog
The default version of show modal shows the dialog occupying the center portion of the screen.

Overrides:
show in class Dialog

autoAdjust

protected void autoAdjust(int w,
                          int h)
Description copied from class: Dialog
Auto adjust size of the dialog. This method is triggered from a sizeChanged event.

Overrides:
autoAdjust in class Dialog
Parameters:
w - width of the screen
h - height of the screen

initModes

protected void initModes()
init all virtual keyboard modes, such as QWERTY_MODE, NUMBERS_SYMBOLS_MODE... to add an addtitional mode a developer needs to override this method and add a mode by calling addInputMode method


setCurrentMode

protected void setCurrentMode(java.lang.String mode)
Sets the current virtual keyboard mode.

Parameters:
mode - the String that represents the mode(QWERTY_MODE, SYMBOLS_MODE, ...)

getCurrentMode

protected java.lang.String getCurrentMode()
Gets the current mode.

Returns:
the String that represents the current mode(QWERTY_MODE, SYMBOLS_MODE, ...)

addDefaultInputMode

public static void addDefaultInputMode(java.lang.String mode,
                                       java.lang.String[][] inputChars)
Add an input mode to the virtual keyboard

Parameters:
mode - a string that represents the identifier of the mode
inputChars - 2 dimensional String array that contains buttons String and special buttons (a special button is identified with $...$ marks e.g: "$Space$")

addInputMode

public void addInputMode(java.lang.String mode,
                         java.lang.String[][] inputChars)
Add an input mode to the virtual keyboard

Parameters:
mode - a string that represents the identifier of the mode
inputChars - 2 dimentional String array that contains buttons String and special buttons (a special button is identified with $...$ marks e.g: "$Space$")

addSpecialButton

public void addSpecialButton(java.lang.String key,
                             Command cmd)
This method adds a special button to the virtual keyboard

Parameters:
key - the string identifier from within the relevant input mode
cmd - the Command to invoke when this button is invoked.

addSpecialButton

public void addSpecialButton(java.lang.String key,
                             Command cmd,
                             int space)
This method adds a special button to the virtual keyboard

Parameters:
key - the string identifier from within the relevant input mode
cmd - the Command to invoke when this button is invoked.
space - how much space in percentage from the overall row the special button should occupy

pointerPressed

public void pointerPressed(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method

Overrides:
pointerPressed in class Form
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerDragged

public void pointerDragged(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer dragged event will call this method

Overrides:
pointerDragged in class Form
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerReleased

public void pointerReleased(int x,
                            int y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method

Overrides:
pointerReleased in class Dialog
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

initSpecialButtons

protected void initSpecialButtons()
This method initialize all the virtual keyboard special buttons.


getInputModeOrder

public java.lang.String[] getInputModeOrder()
Returns the order in which input modes are toggled

Returns:
the order of the input modes

setInputModeOrder

public void setInputModeOrder(java.lang.String[] order)
Sets the order in which input modes are toggled and allows disabling/hiding an input mode

Parameters:
order - the order for the input modes in this field

getDefaultInputModeOrder

public static java.lang.String[] getDefaultInputModeOrder()
Returns the order in which input modes are toggled by default

Returns:
the default order of the input mode

setDefaultInputModeOrder

public static void setDefaultInputModeOrder(java.lang.String[] order)
Sets the order in which input modes are toggled by default and allows disabling/hiding an input mode

Parameters:
order - the order for the input modes in all future created fields

actionCommand

protected void actionCommand(Command cmd)
Description copied from class: Dialog
Invoked to allow subclasses of form to handle a command from one point rather than implementing many command instances

Overrides:
actionCommand in class Dialog
Parameters:
cmd - the action command

dispose

public void dispose()
Description copied from class: Dialog
Closes the current form and returns to the previous form, releasing the EDT in the process

Overrides:
dispose in class Dialog

onShow

protected void onShow()
Description copied from class: Form
Allows subclasses to bind functionality that occurs when a specific form or dialog appears on the screen

Overrides:
onShow in class Dialog

getInputField

protected TextField getInputField()
This method returns the Virtual Keyboard TextField.

Returns:
the the Virtual Keyboard TextField.

setCommitOnDispose

public static void setCommitOnDispose(TextField tf,
                                      boolean b)
Indicates whether the VKB should commit changes to the text field when the VKB is closed not via the OK button. This might be useful for some situations such as searches

Parameters:
tf - the text field to mark as commit on dispose
b - the value of commit on dispose, true to always commit changes

bindVirtualKeyboard

public static void bindVirtualKeyboard(TextArea t,
                                       VirtualKeyboard vkb)
This method is used to bind a specific instance of a virtual keyboard to a specific TextField. For example if a specific TextField requires only numeric input consider using this method as follows: TextField tf = new TextField(); tf.setConstraint(TextField.NUMERIC); tf.setInputModeOrder(new String[]{"123"}); VirtualKeyboard vkb = new VirtualKeyboard(); vkb.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_MODE}); VirtualKeyboard.bindVirtualKeyboard(tf, vkb);

Parameters:
t - the TextField to bind a VirualKeyboard to.
vkb - the binded VirualKeyboard.

getVirtualKeyboard

public static VirtualKeyboard getVirtualKeyboard(TextArea t)
This method returns the Textfield associated VirtualKeyboard, see bindVirtualKeyboard(TextField tf, VirtualKeyboard vkb) method.

Parameters:
t - a TextField.that might have an associated VirtualKeyboard instance
Returns:
a VirtualKeyboard instance or null if not exists.

isCommitOnDispose

public static boolean isCommitOnDispose(TextArea tf)
Indicates whether the given text field should commit on dispose

Parameters:
tf - the text field
Returns:
true if the text field should save the data despite the fact that it was disposed in an irregular way

setVKBTint

public static void setVKBTint(TextField tf,
                              int tint)
Sets the tint color for the virtual keyboard when shown on top of this text field see the form tint methods for more information

Parameters:
tf - the relevant text field
tint - the tint color with an alpha channel

getVKBTint

public static int getVKBTint(TextArea tf)
The tint color for the virtual keyboard when shown on top of this text field see the form tint methods for more information

Parameters:
tf - the relevant text field
Returns:
the tint color with an alpha channel

isShowTooltips

public static boolean isShowTooltips()
Indicates whether tooltips should be shown when the keys in the VKB are pressed

Returns:
the showTooltips

setShowTooltips

public static void setShowTooltips(boolean aShowTooltips)
Indicates whether tooltips should be shown when the keys in the VKB are pressed

Parameters:
aShowTooltips - true to show tooltips

getTransitionIn

public static Transition getTransitionIn()
The transition in for the VKB

Returns:
the transitionIn

setTransitionIn

public static void setTransitionIn(Transition aTransitionIn)
The transition in for the VKB

Parameters:
aTransitionIn - the transitionIn to set

getTransitionOut

public static Transition getTransitionOut()
The transition out for the VKB

Returns:
the transitionOut

setTransitionOut

public static void setTransitionOut(Transition aTransitionOut)
The transition out for the VKB

Parameters:
aTransitionOut - the transitionOut to set

showKeyboard

public void showKeyboard(boolean show)
Shows the virtual keyboard that is assoiciated with the displayed TextField or displays the default virtual keyboard.

Specified by:
showKeyboard in interface VirtualKeyboardInterface
Parameters:
show - it show is true open the relevant keyboard, if close dispose the displayed keyboard

setDefaultVirtualKeyboardClass

public static void setDefaultVirtualKeyboardClass(java.lang.Class vkbClazz)
Sets the default virtual keyboard class for the com.sun.lwuit.VirtualKeyboard type This class is used as the default virtual keyboard class if the current platform VirtualKeyboard is com.sun.lwuit.VirtualKeyboard. Platform VirtualKeyboard is defined here: Display.getIntance().setDefaultVirtualKeyboard(VirtualKeyboardInterface vkb)

Parameters:
vkbClazz - this class must extend VirtualKeyboard.

getVirtualKeyboardName

public java.lang.String getVirtualKeyboardName()
Description copied from interface: VirtualKeyboardInterface
Returns the Virtual Keyboard name. This is a unique indentifier for the Virtual Keyboard implementation

Specified by:
getVirtualKeyboardName in interface VirtualKeyboardInterface
Returns:
a unique id that represents this virtual keyboard.
See Also:
VirtualKeyboardInterface

isVirtualKeyboardShowing

public boolean isVirtualKeyboardShowing()
Description copied from interface: VirtualKeyboardInterface
Indicates if the Virtual Keyboard is currently showing.

Specified by:
isVirtualKeyboardShowing in interface VirtualKeyboardInterface
Returns:
true if the Virtual Keyboard is currently showing
See Also:
VirtualKeyboardInterface