I'm using the last version of LWUIT (1.5). I designed my forms in resource editor and then generate the code to netbeans. The problem is if i want to access any object except the form i got this error:
java.lang.NullPointerException at userclasses.StateMachine.onCtnCalculation_BtnAddAction(StateMachine.java:38) at generated.StateMachineBase.handleComponentAction(StateMachineBase.java:712) at com.sun.lwuit.util.UIBuilder$FormListener.actionPerformed(UIBuilder.java:2231) at com.sun.lwuit.util.EventDispatcher.fireActionSync(EventDispatcher.java:312) at com.sun.lwuit.util.EventDispatcher.fireActionEvent(EventDispatcher.java:257) at com.sun.lwuit.Button.fireActionEvent(Button.java:364) at com.sun.lwuit.Button.released(Button.java:395) at com.sun.lwuit.Button.released(Button.java:384) at com.sun.lwuit.Button.keyReleased(Button.java:413) at com.sun.lwuit.Form.keyReleased(+64) at com.sun.lwuit.Display.handleEvent(Display.java:1533) at com.sun.lwuit.Display.edtLoopImpl(Display.java:826) at com.sun.lwuit.Display.mainEDTLoop(Display.java:776) at com.sun.lwuit.RunnableWrapper.run(RunnableWrapper.java:119)
This is my code:
protected void onCtnCalculation_BtnAddAction(Component c, ActionEvent event) {
// If the resource file changes the names of components this call will break notifying you that you should fix the code
super.onCtnCalculation_BtnAddAction(c, event);
Form root = Display.getInstance().getCurrent();
TextField txtAmount = findTxtAmount(root);
fltAmount += Float.parseFloat(txtAmount.getText());
}
also i tried this:
fltAmount += Float.parseFloat(findTxtAmount(root).getText());