| ID | KIJ001374 | Creation date | June 12, 2009 |
| Platform | S60 5th Edition | Devices | Nokia 5800 XpressMusic |
| Category | Java ME | Subcategory | UI |
| Keywords (APIs, classes, methods, functions): TextBox.setMaxSize(int) |
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.
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);
t.addCommand(cmd);
t.setCommandListener(this);
d=Display.getDisplay(this);
}
public void startApp() {
d.setCurrent(t);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable displayable)
{
if(command == cmd)
try
{
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.
No related wiki articles found