MainScreen(midlet)
public class MainScreen extends MIDlet implements CommandListener {
private Display display;
private List list = new List("The Game:", List.IMPLICIT);
private Command exit = new Command("Exit", Command.EXIT, 1);
Alert alert;
public MainScreen() {
display = Display.getDisplay(this);
list.append("New Game", null);
list.append("High Score", null);
list.append("Settings", null);
list.addCommand(exit);
list.setCommandListener(this);
}
public void startApp() {
display.setCurrent(list);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable displayable) {
if (command == List.SELECT_COMMAND) {
String selection = list.getString(list.getSelectedIndex());
} else if (command == exit) {
destroyApp(false);
notifyDestroyed();
}
}
}
SettingsScreen.java
public class SettingsScreen extends Form
{
private String name;
private TextField txtName = new TextField("Your Name:", "", 10, TextField.ANY);
private Command back = new Command("Back", Command.BACK, 2);
private Command cmSettings;
private Form fmMain;
public SettingsScreen(String title, MainScreen main, int highscore)
{
super(title);
append(txtName);
append(new StringItem("Highscore: ", String.valueOf(highscore)));
addCommand(back);
this.setCommandListener(main);
}
}

New Topic/Question
Reply


MultiQuote


|