Double double;
int integer = (int) Math.round(double);
String string = Integer.toString(integer);
System.out.println(string);
findTxtField().setText(string);
I am using the above code as An EXAMPLE- I have coded my mobile application using CodeNameOne. The variables are initialized.
I am receiving an error message when running the mobile application and hitting the button that executed similar code(above), unfortunately, after troubleshooting I figured out it was the outputting to the text-field that was causing the crash.
My Mobile application has 5 UI sections. The section for user "registration" will take the data, calculate it and then output the data using a text-field on another UI section "Results".
Any Idea why I am having this issue?
Error:
java.lang.NullPointerException
at userclasses.StateMachine.onMain_BtnInfoAction(StateMachine.java:171)
at generated.StateMachineBase.handleComponentAction(StateMachineBase.java:2251)
at com.codename1.ui.util.UIBuilder$FormListener.actionPerformed(UIBuilder.java:2831)
at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:345)
at com.codename1.ui.Button.fireActionEvent(Button.java:397)
at com.codename1.ui.Button.released(Button.java:428)
at com.codename1.ui.Button.pointerReleased(Button.java:516)
at com.codename1.ui.Form.pointerReleased(Form.java:2560)
at com.codename1.ui.Form.pointerReleased(Form.java:2496)
at com.codename1.ui.Component.pointerReleased(Component.java:3108)
at com.codename1.ui.Display.handleEvent(Display.java:2017)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1065)
at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)