Namespaces
Variants
Actions

Archived:TextField.setString() may throw an IllegalArgumentException in Series 40 2nd Edition devices if TextField.DECIMAL is used (Known Issue)

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata

Article
Created: User:Technical writer 1 (07 Feb 2008)
Last edited: hamishwillee (28 Jun 2012)
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 

Contents

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.

This page was last modified on 28 June 2012, at 08:55.
149 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved