import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.TextBox; public class WriteText implements CommandListener { Displayable backscreen; public static String gtext; public TextBox textbox; public Command exit,ok; WriteText() {} public void text(String title,String text,int maxsize,int constraints) { backscreen=Main.display.getCurrent(); ok = new Command("",Command.OK,1); exit = new Command("",Command.BACK,2); textbox = new TextBox(title,text,maxsize,constraints); textbox.addCommand(exit); textbox.addCommand(ok); textbox.setCommandListener(this); Main.display.setCurrent(textbox); } public void commandAction(Command command,Displayable displayable) { if (command == exit) { Main.display.setCurrent(backscreen); } if (command == ok) { gtext=textbox.getString(); Main.display.setCurrent(backscreen); } } }