1

how can I create a TextField ..plz help me out in LWUIT

TextField pin = new TextField ("",TextField.PASSWORD|TextField.URL);
cashpayform.addComponent(pin);
cashpayform.show();
 cashpayform.addCommand(exit);
        cashpayform.setCommandListener(this);
 cashpayform.show();
bharath
  • 14,283
  • 16
  • 57
  • 95
RNZN
  • 107
  • 3
  • 12

2 Answers2

4

Use this code,

 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();
bharath
  • 14,283
  • 16
  • 57
  • 95
  • yeah. You can't use the same textfield. Create a new instance of that textfield and use it another form. – bharath Jul 07 '11 at 09:48
  • I'm asking 1 question. Why do want to use same textfield on another form? – bharath Jul 07 '11 at 10:35
  • becoz the another form also have the same txctfield.. Form1 contains txtfield sender name and form2 also contains the same txtfield sender name so – RNZN Jul 07 '11 at 10:50
  • You can create the new textfield. and get the sender name from Form1 txtfield and set that sender name into Form2 txtfield. Got it? – bharath Jul 07 '11 at 10:56
  • i didn't mean this... i was asking if a textfield declared once again be used throughout the pgm in another form or not.... the sender name doesnot need to be same ... the operation are different – RNZN Jul 07 '11 at 11:00
  • once you added the textfield into Form means you can't use that textfield throughout the project. Two solutions 1. create new textfield 2. create the new instance(that means initialize the textfield again) – bharath Jul 07 '11 at 11:10
  • you have to initialize the textfield again. That means `textField = new TextField();`. – bharath Jul 07 '11 at 11:42
  • ok thanx.. if I have any prob in that i shall consult u.. plz dont mind ansering;) – RNZN Jul 07 '11 at 12:10
  • Ok. I regularly using satckoverflow. You can ask and everyone helps you. – bharath Jul 07 '11 at 12:15
  • how can I set the location of the button – RNZN Jul 08 '11 at 04:59
3
TextField tf = new TextField();
tf.setConstraint(TextArea.PASSWORD | TextArea.URL);

make sure that TextField and Form are classes of lwuit

Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46
  • thanx for the help... can u tell me how can I limit the textfield length to 4 – RNZN Jul 07 '11 at 08:59
  • hello how can I set the location of a button? – RNZN Jul 08 '11 at 04:58
  • @RNZN, if you want to thank someone, you should consider either accepting his/her answer or upvoting it, I suggest you to read the faq, but welcome to the community anyway! – mdelolmo Jul 08 '11 at 19:04