J2ME双值问题
做了一些操作后,我无法在 TextField 中显示双精度值 对其进行处理。基本上,我只是将摄氏度转换为 转换器应用程序中的 FarenHeit。 这是代码
double c = Double.parseDouble(t1.getString()); double f = c * (9.0D/5.0D) + 32.0D; Netbeans is giving me the following runtime error TRACE: , Exception caught in Display class java.lang.IllegalArgumentException at javax.microedition.lcdui.TextField.setCharsImpl(), bci=127 at javax.microedition.lcdui.TextField.setString(), bci=37 at ConverterMain.convert(ConverterMain.java:139) at ConverterMain.commandAction(ConverterMain.java:66) at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 at com.sun.midp.chameleon.layers.SoftButtonLayer.commandSelected(), bci=11 at com.sun.midp.chameleon.layers.MenuLayer.keyInput(), bci=290 at com.sun.midp.chameleon.CWindow.keyInput(), bci=38 at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=17 at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277 at com.sun.midp.events.EventQueue.run(), bci=179 at java.lang.Thread.run(Thread.java:619)
I am not able to display the double value in the TextField after doing some
processing on it. Basically, I am just converting Celcius to
FarenHeit in a Converter Application.
Here is the code
double c = Double.parseDouble(t1.getString()); double f = c * (9.0D/5.0D) + 32.0D; Netbeans is giving me the following runtime error TRACE: , Exception caught in Display class java.lang.IllegalArgumentException at javax.microedition.lcdui.TextField.setCharsImpl(), bci=127 at javax.microedition.lcdui.TextField.setString(), bci=37 at ConverterMain.convert(ConverterMain.java:139) at ConverterMain.commandAction(ConverterMain.java:66) at javax.microedition.lcdui.Display$ChameleonTunnel.callScreenListener(), bci=46 at com.sun.midp.chameleon.layers.SoftButtonLayer.processCommand(), bci=74 at com.sun.midp.chameleon.layers.SoftButtonLayer.commandSelected(), bci=11 at com.sun.midp.chameleon.layers.MenuLayer.keyInput(), bci=290 at com.sun.midp.chameleon.CWindow.keyInput(), bci=38 at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=17 at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277 at com.sun.midp.events.EventQueue.run(), bci=179 at java.lang.Thread.run(Thread.java:619)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
setString
表示在field中设置时将其转换为字符串
setString
means convert it to string while setting in field
这么少的代码很难说清楚。
如果我是你,我会添加一些日志,例如
你确定 t1.getString() 是有效的 Double 吗?
尝试使用 try-catch 块
It is hard to tell with so little code.
If I were you I would add a couple of logs like
Are you sure t1.getString() is a valid Double?
Try using a try-catch block