
Originally Posted by
valderind4
I thought more about this case...
So I think you should using TextField, because TextBox is a displayable so You can not diplaying 4, but just one is possible. Now is using TextField You can use many...
But you told TextBox...I made an example using too TextBox, where you can change of the one TextBox to another...
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class DoubleTextBoxTest extends MIDlet implements CommandListener {
private Display display;
private TextBox textBox1;
private TextBox textBox2;
private Command exit;
private Command changeTextBoxCommand;
public DoubleTextBoxTest() {
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 0);
this.changeTextBoxCommand=new Command("ChangeTextBox", Command.OK, 1);
textBox1=new TextBox("TextBox1", "press ChangeTextBox command for to change the current" +
" textBox", 150, 0);
textBox1.addCommand(exit);
textBox1.addCommand(changeTextBoxCommand);
textBox1.setCommandListener(this);
textBox2=new TextBox("TextBox2", "press ChangeTextBox command for to change the current" +
" textBox", 150, 0);
textBox2.addCommand(exit);
textBox2.addCommand(changeTextBoxCommand);
textBox2.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(textBox1);
}
public void commandAction(Command command, Displayable d) {
if (command == exit) {
try {
this.destroyApp(true);
} catch (MIDletStateChangeException e) {
e.printStackTrace();
} finally {
this.notifyDestroyed();
}
}
if((d==textBox1) && (command==changeTextBoxCommand)){
display.setCurrent(textBox2);
}
else if((d==textBox2) && (command==changeTextBoxCommand)){
display.setCurrent(textBox1);
}
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {}
protected void pauseApp() {}
}