Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

TextBox.setMaxSize(int) for Pop-Up TextBox not working correctly in S60 5th Edition (Known Issue)

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
S60 5th Edition
Created: User:Technical writer 1 (12 May 2009)
Last edited: hamishwillee (09 Aug 2013)


Starting from S60 3rd Edition, Feature Pack 2, it is possible to set TextBox to appear as a Pop-Up component in certain devices. This is done by using the JAR attribute and value Nokia-UI-Enhancement: PopUpTextBox.

TextBox.setMaxSize(int) can be used to set the maximum number of characters that the component can contain. If this limitation is set for a TextBox that contains an amount of characters that exceeds the maximum, the content of the TextBox will be truncated.

However, in S60 5th Edition, setMaxSize(int) for a Pop-Up TextBox does not have the desired effect.

How to reproduce

1. Implement a test MIDlet with a Pop-Up TextBox. You can use, for example, the following source code:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SetMaxSizeTest extends MIDlet implements CommandListener{
TextBox t;
Display d;
Command cmd;
public SetMaxSizeTest(){
t=new TextBox("Type here", "", 100, 2); // TextBox
cmd = new Command("SetMaxSize to 2", Command.SCREEN, 0);
public void startApp() {
public void pauseApp() {
public void destroyApp(boolean unconditional) {
public void commandAction(Command command, Displayable displayable)
if(command == cmd)
t.setMaxSize(2); // maximum number of characters set to 2
catch(IllegalArgumentException iae)
Display.getDisplay(this).setCurrent(new Alert("Exception thrown", iae.getMessage(), null, AlertType.INFO));

In addition to the code, include the following JAD attribute and its value in the JAD file:

Nokia-UI-Enhancement: PopUpTextBox

2. Launch the application and type text that exceeds the setMaxSize(int) limit (here: 2) into the TextBox.

3. Select the SetMaxSize to 2 command. On the affected devices, the text that exceeds the set maximum is not truncated.


This issue is expected to be fixed in future S60 5th Edition devices.

This page was last modified on 9 August 2013, at 04:48.
23 page views in the last 30 days.