Before I decided to make this question I've searched the answer here but didn't find. Sorry for my bad inglish but it isn't my native language.

Here's my problem:

I've made an LWUIT 1.5 app generated from the Resource editor into Netbeans, and I want to customize the VirtualKeyboard with my own buttons and then bind them to a TextField but I dont't know WHERE to put the code. I've tried putting it into the BeforeShow my Form "MyForm", or in PostShow like this:

protected void beforeMyForm(Form f) {
   // If the resource file changes the names of components this call will break notifying you that you should fix the code
super.beforeMyForm(f);

VirtualKeyboard vkb = new VirtualKeyboard();

//I declared the new input
String[][] CALC_NUM = new String[][]{
        {"1", "3", "5",},
        {"7", "9", "0",},
        {".","$OK$"}
};
//Added the new input mode
vkb.addInputMode("137_C", CALC_NUM);
vkb.setInputModeOrder(new String[]{"137_C"});

//Bind the vkb to my TextField
VirtualKeyboard.bindVirtualKeyboard(findTfCalc(Display.getInstance().getCurrent()), vkb);

}

In beforeShow theres a NullPointerException and in postShow nothing happens.

In the Properties of the TextField the constraint is Numeric. I know there's a bug with Numeric and Password constraint but I've tried giving the ANY constraint to the TextField, but its not working.

Could someone give me a hand with it?. It would be the same way in Codenameone? Many thanks.

1

There are 1 best solutions below

3
On

You are using Display.getInstance().getCurrent() instead of using the f, in the before show method the new form isn't yet the current form.

http://codenameone.blogspot.com/2010/06/pimp-virtualkeyboard-by-chen-fishbein.html