• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Why won't my BACK BUTTON work?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a short program to take me from a menu list to a form and back.
But my back button won't work. Can you tell me why? Thanks.

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class Testing extends MIDlet implements CommandListener {
private Command exitCommand = new Command("Exit", Command.EXIT, 2);
private Command goCommand = new Command("Go", Command.OK, 2);
private Command backCommand = new Command("Back", Command.BACK, 2);
private Display display;
private Alert resultAlert;
private List list;
public static final String[] items = {"Choice 1", "Choice 2", "Choice 3", "Choice 4"};
public Testing() {
display = Display.getDisplay(this);
list = new List("", List.IMPLICIT, items, null);
list.addCommand(exitCommand);
list.addCommand(goCommand);
list.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
display.setCurrent(list);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
int len, i;
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
} else if (c == goCommand) {
Form resultSet = new Form("Results of Your Search");
String[] strings = {"Here is a page", "written by a sage"};
len = strings.length;
for (i=0; i<len; i++ ) {
resultSet.append(strings[i] + "\n");
}
resultSet.addCommand(backCommand);
display.setCurrent(resultSet);
}
}
}
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it needs to see a Chiropractor?

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, because there is no code in the commandAction method to handle the user selecting the command


BACK

public static final int BACK

A navigation command that returns the user to the logically previous screen. The jump to the previous screen is not done automatically by the implementation but by the commandAction provided by the application. Note that the application defines the actual action since the strictly previous screen may not be logically correct.
Value 2 is assigned to BACK.

See Also:



Mark
 
ruffy me
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark!
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic