2011-07-07 49 views
1

我怎麼可以創建一個文本字段..plz幫我在LWUITLWUIT J2ME文本框

TextField pin = new TextField ("",TextField.PASSWORD|TextField.URL); 
cashpayform.addComponent(pin); 
cashpayform.show(); 
cashpayform.addCommand(exit); 
     cashpayform.setCommandListener(this); 
cashpayform.show(); 

回答

3
TextField tf = new TextField(); 
tf.setConstraint(TextArea.PASSWORD | TextArea.URL); 

確保TextField和形式LWUIT類

+0

thanx的幫助...你能告訴我如何限制文本字段的長度爲4 – RNZN

+0

tf.setColumns(4); –

+0

你好我怎樣才能設置一個按鈕的位置? – RNZN

4

使用此代碼,

Form form = new Form("Sample"); 
form.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); 
TextField textField = new TextField(); 
textField.setConstraint(TextField.PASSWORD | TextField.URL); 
textField.setMaxSize(100); 
form.addComponent(textField); 
form.addCommand(new Command("Exit") { 

    public void actionPerformed(ActionEvent evt) { 
     notifyDestroyed(); 
    } 
}); 
form.show(); 
+0

thanx .....我們不能使用不同形式的相同文本字段嗎? – RNZN

+0

是的。您不能使用相同的文本框。創建該文本字段的新實例並將其用於另一種形式。 – bharath

+0

PLZ幫助我如何創建一個實例..從來沒有做過B4 – RNZN