J 2 ME共通コンポーネントテスト
詳細
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.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/*
: TextBox , ,
:TextField.ANY TextField.EMAILADDR TextField.NUMERIC TextField.DECIMAL
TextField.PHONENUMBER TextField.URL
*
*
*/
//
public class TextBox_test extends MIDlet implements CommandListener {
private Display display;
public TextBox_test(){
super();
//
display = Display.getDisplay(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
//textBox
// :title, , ,
TextBox tb = new TextBox(" ","",200,TextField.ANY);
tb.addCommand(new Command(" ",Command.OK,1));
tb.setCommandListener(this);
display.setCurrent(tb);
}
public void commandAction(Command c, Displayable d) {
// TODO Auto-generated method stub
if(c.getLabel().equals(" ")){
TextBox tb = (TextBox)d;
int maxValue = tb.getMaxSize();
String content = tb.getString();
System.out.println(" :"+content);
}
}
}