Sie können aktuelle Form erhalten, die bereits mit „Display.getCurrent()“ Zum Beispiel ist die Anzeige dieser Leinwand ist ein Splashscreen, die aktuelle Form vor Anzeigen im Fenster:
import javax.microedition.lcdui.Canvas;
/* */ import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
/* */ import javax.microedition.lcdui.Graphics;
/* */ import javax.microedition.lcdui.Image;
public class StaticSplashScreen extends Canvas
implements Runnable {
private HelloMIDlet mainMidlet;
private boolean isSplashOver;
private long currentTime;
private long previousTime;
private Form currentForm;
public StaticSplashScreen(HelloMIDlet mid) {
this.mainMidlet = mid;
currentForm = (Form) this.mainMidlet.getDisplay().getCurrent();
this.previousTime = System.currentTimeMillis();
new Thread(this).start();
}
protected void paint(Graphics g) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0, 0, 0);
g.drawString("In the name of God", 40, 70, 0);
}
public void run() {
while (!this.isSplashOver) {
this.currentTime = System.currentTimeMillis();
if (this.currentTime - this.previousTime >= 10000L) {
this.isSplashOver = true;
}
}
this.mainMidlet.getDisplay().setCurrent(currentForm);
}
}
In diesem midlet Sie können zwei Formen mit einigen commands.When sehen Sie „Hilfe“ in jeder Form, Methode() Anrufe und Splashscreen diplays und nach 10 Sekunden drücken, können Sie das Formular sehen, dass sie wieder ins Leben gerufen:
public class HelloMIDlet extends MIDlet implements CommandListener {
...
public void commandAction (Command command, Displayable displayable) {
...
if (command == helpCommand) {
method();
}
...
}
public Form getForm() {
if (form == null) {
form = new Form ("Welcome");
form.addCommand (getHelpCommand());
form.setCommandListener (this);
}
return form;
}
public void method() {
if (true) {
StaticSplashScreen sss = new StaticSplashScreen(this);
this.getDisplay().setCurrent(sss);
} else {
}
}
public Form getForm1() {
if (form1 == null) {
form1 = new Form ("form1");
form1.addCommand (getHelpCommand());
form1.setCommandListener (this);
}
return form1;
}
}
können Sie zeige Codeschnipsel, die yo demonstrieren Dein Problem? vorzugsweise [SSCCE] (http://www.sscce.org/ "Kurz, eigenständig, korrekt (kompilierbar), Beispiel") – gnat
verwenden müssen Leinwand .... nicht J2me Formular ... – Baba