Hi,
ich habe ein JavaMe-Projekt in Netbeans erstellt und dort mehrere .Java-Dateien eingefügt, die jeweils ein MIDlet enthalten. Wenn ich in dem ersten MIDlet etwas drücke o.ä. dann möchte ich gern, dass MIDlet 2 geöffnet wird und dessen Form angezeigt wird.
So sieht z.B. ein MIDlet aus:
ich habe ein JavaMe-Projekt in Netbeans erstellt und dort mehrere .Java-Dateien eingefügt, die jeweils ein MIDlet enthalten. Wenn ich in dem ersten MIDlet etwas drücke o.ä. dann möchte ich gern, dass MIDlet 2 geöffnet wird und dessen Form angezeigt wird.
So sieht z.B. ein MIDlet aus:
Java:
package menu;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class KlassenName extends MIDlet implements CommandListener {
private boolean midletPaused = false;
private Form form;
private Command exitCommand;
/**
* The KlassenName constructor.
*/
public KlassenName() {
}
private void initialize() {
// write initialize user code here
}
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {
switchDisplayable(null, getForm());
}
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {
// write action user code here
}
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
}
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
if (displayable == form) {
if (command == exitCommand) {
exitMIDlet();
}
}
}
/**
* Returns an initiliazed instance of form component.
* @return the initialized component instance
*/
public Form getForm() {
if (form == null) {
form = new Form("Learn Everything");
form.addCommand(getExitCommand());
form.setCommandListener(this);
}
return form;
}
/**
* Returns an initiliazed instance of exitCommand component.
* @return the initialized component instance
*/
public Command getExitCommand() {
if (exitCommand == null) {
exitCommand = new Command("Exit", Command.EXIT, 0);
}
return exitCommand;
}
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay () {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable (null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet ();
} else {
initialize ();
startMIDlet ();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
}