We help IT Professionals succeed at work.

J2ME... Setting Focus on a Text Field

NerdyMike
NerdyMike asked
on
Medium Priority
6,315 Views
Last Modified: 2010-08-05
Hopefully a really simple one today...  I have a form with a number of fields:

        timeForm = new Form("Time");
        timeinPSTField = new TextField("PST Time In or Minutes?", "", 4, TextField.NUMERIC);
        timeoutPSTField = new TextField("PST Time Out or 0?", "", 4, TextField.NUMERIC);
        timeinField = new TextField("EXEMPT Time In or Minutes?", "", 4, TextField.NUMERIC);
        timeoutField = new TextField("EXEMPT Time Out or blank?", "", 4, TextField.NUMERIC);
        timeForm.append(timeinPSTField);
        timeForm.append(timeoutPSTField);
        timeForm.append(timeinField);
        timeForm.append(timeoutField);
        timeForm.addCommand(okCommand);
        timeForm.addCommand(exitCommand);
        timeForm.setCommandListener(this);

How do I set the focus to a specific field...  Ie - Something like timeoutPSTField.setFocus().

Thanks in advance!

-Mike
Comment
Watch Question

Commented:
You can do it this way:

yourMidlet.getDisplay().setCurrentItem(timeoutPSTField);

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
So easy when you get the exact code!  I looked on Google for 45 minutes and couldn't easily find it!  (I found similar ones but not as precise as yours).


Thanks!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.