This page was last modified 11:32, 7 February 2008.
KIJ000813 - TextField.setString() may throw an IllegalArgumentException in Series 40 2nd Edition devices if TextField.DECIMAL is used
From Forum Nokia Wiki
| ID | KIJ000813 | Creation date | February 7, 2008 |
| Platform | Series 40 2nd Edition Early firmware versions of Series 40 3rd Edition | Devices | Nokia 3220, Nokia 5070 |
| Category | Java ME | Subcategory | MIDP 2.0 |
Overview
TextField.setString(Double.toString(Math.PI)) throws IllegalArgumentException in Series 40 2nd Edition devices.
Description
TextField.setString(Double.toString(Math.PI)) throws IllegalArgumentException in Series 40 2nd Edition devices. This appears to be because maximum amount of decimal digits is exceeded: if there are more than 8 decimal digits after the decimal point, the defined exception will be thrown. Double.toString(Math.PI) returns a String of 17 characters (15 digits).
How to reproduce
Try this:
TextField txt;
..
txt = new TextField("Value:", "", 20, TextField.DECIMAL);
txt.setString(Double.toString(Math.PI));
Or this:
TextField txt;
..
txt = new TextField("Value:", "", 20, TextField.DECIMAL);
textField.setString("3.141592653");
Solution
Avoid reading more than 8 digits or use String.substring(int beginIndex, int endIndex) for shortening the String or use TextField of type ANY.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to show an Alert when a TextField value changes? (7210) | ionutianasi | Mobile Java General | 0 | 2003-08-29 08:22 |
| Sending SMS via XHTML | controlsee | Browsing and Mark-ups | 4 | 2005-03-31 19:23 |
| Could I add a new input mode into the phone? | zhouhuayu | Mobile Java General | 9 | 2006-05-11 18:20 |
| Call a function when a value is entered in a TextField | LuTHieR | Mobile Java General | 5 | 2006-10-20 14:07 |
| Accessing T9 dictionary word list from J2ME app | steve_j76 | Mobile Java General | 3 | 2008-03-06 13:47 |

