package textfield;
import java.io.IOException;
import java.util.Hashtable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.sun.lwuit.Button;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.TextField;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
public class FloatTextField extends MIDlet {
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO 自动生成方法存根
}
protected void pauseApp() {
// TODO 自动生成方法存根
}
protected void startApp() throws MIDletStateChangeException {
// TODO 自动生成方法存根
Display.init(this);
try {
Resources theme = Resources.open("/LWUITtheme.res");
UIManager.getInstance().setThemeProps(
theme.getTheme(theme.getThemeResourceNames()[0]));
} catch (IOException e) {
e.printStackTrace();
}
showForm();
}
public void showForm() {
Form f = new Form("测试TextField 的电话号码输入");
f.setLayout(new BorderLayout());
final Button add = new Button("add");
Hashtable ht = new Hashtable();
ht.put(new Integer('0'), "0");
ht.put(new Integer('9'), "9");
ht.put(new Integer('8'), "8");
ht.put(new Integer('7'), "7");
ht.put(new Integer('6'), "6");
ht.put(new Integer('5'), "5");
ht.put(new Integer('4'), "4");
ht.put(new Integer('3'), "3");
ht.put(new Integer('2'), "2");
ht.put(new Integer('1'), "1");
ht.put(new Integer('#'), "+");
TextField.addInputMode("+123", ht, false);
final TextField tf = new TextField();
tf.setConstraint(TextArea.PHONENUMBER);
tf.setInputMode("+123");
tf.setInputModeOrder(new String[]{"+123"});
f.addComponent(BorderLayout.NORTH, tf);
f.addComponent(BorderLayout.SOUTH, add);
f.show();
}
}
lwuit TextField 输入法
最新推荐文章于 2023-01-28 18:02:59 发布