This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes Using a Textfield to switch to displayables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Using a Textfield to switch to displayables" Watch "Using a Textfield to switch to displayables" New topic
Author

Using a Textfield to switch to displayables

Ken Waribo
Greenhorn

Joined: Dec 27, 2012
Posts: 1
I'm working with java me, I built an app using forms displayables. I'm trying to switch to other forms, based on the user'sinput in a textfield item. For example, I want the user to be able to type in the number "1" in the textfield and then be taken to form1 or type in "2" and be taken to form2 etc.
Here's what I did.
I added a command to the textfield item and listen on it to read textfield contents and then compare the contents as a string, to switch forms. I don't know whymy code isn't working. I think maybe there's something I'm missing or my logicis not right. I'd really appreciate any help on this please.
form.setCommandListener(new CommandListener() {
public void commandAction(Command command, Displayable displayable) {
if (command == getTextFieldItemCommand()) {
if ("1".equals(TextField.getString())) {
switchDisplayable(null, form1);
} else if ("2".equals(TextField.getString())){
switchDisplayable(null, form2);
}
}
}
 
Consider Paul's rocket mass heater.
 
subject: Using a Textfield to switch to displayables
 
Similar Threads
failing to get login right from servlet and midlet
how to upload form data and image using jsp
how can I make two actions communicate with each other
Network error in first Servletjava.lang.NullPointerException in java wireless toolkit
Warning: To avoid potential deadlock networking, should be performed in a diff.thread.