How to run example?
Hi. I am new to J2ME and am trying to do this tutorial with Wireless Toolkit 2.5 for CLDC
I create the class and Build successful, but I can't run it.
(The error in console is : Unable to create MIDlet BasicUI
java.lang.ClassNotFoundException: BasicUI
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Selector.run(+22))
This is the examle I am doing:
package mymidlet;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class BasicUI extends MIDlet implements CommandListener {
Display display = null;
List introMenu = new List("This is a list" , List.IMPLICIT);
Form testForm = new Form("A Form");
TextBox testText = new TextBox("Enter text", "Initial contents", 160, 0);
Alert changeAlert = null;
Ticker ticker = new Ticker(
"Valmur, Ithink this is the beginning of a beautiful friendship.");
static final Command backCommand = new Command("Back",Command.BACK, 0);
static final Command exitCommand = new Command("Exit",Command.STOP, 2);
public BasicUI(){
display = Display.getDisplay(this);
introMenu.append("See a form", null);
introMenu.append("See a text box", null);
introMenu.append("See a an alert demo", null);
introMenu.addCommand(exitCommand);
introMenu.setCommandListener(this);
}
public void startApp(){
setIntroMenu(true);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
notifyDestroyed();
}
private void setIntroMenu(boolean firstTime) {
if (firstTime) {
introMenu.setTicker(ticker);
display.setCurrent(introMenu);
}
else {
ticker.setString("Wasn't that exciting!?");
introMenu.setTicker(ticker);
display.setCurrent(introMenu);
}
}
private void runFormDemo(){
TextField someText = new TextField("A test..", ".with text in a form", 20, 0);
testForm.append(someText);
Gauge gauge = new Gauge("Set desired level", true, 20, 0);
testForm.append(gauge);
testForm.addCommand(backCommand);
testForm.setCommandListener(this);
display.setCurrent(testForm);
}
private void runTextDemo(){
testText.addCommand(backCommand);
testText.setCommandListener(this);
display.setCurrent(testText);
}
private void runAlertDemo(){
changeAlert = new Alert("Changing...");
changeAlert.setString("Moving to the main menu");
changeAlert.setType(AlertType.INFO);
changeAlert.setTimeout(5000);
display.setCurrent(changeAlert);
}
public void commandAction(Command activated, Displayable origin){
String commandLabel = activated.getLabel();
System.out.println(commandLabel + "has been activated");
if(commandLabel.equals("Exit")){
destroyApp(true);
}
else if(commandLabel.equals("Back")){
setIntroMenu(false);
}
if (activated.equals(List.SELECT_COMMAND)){
System.out.println("List option selected");
switch(introMenu.getSelectedIndex()){
case 0: runFormDemo(); break;
case 1: runTextDemo(); break;
case 2: runAlertDemo(); break;
}
}
}
}
I don't know, what to do and where is my error?

