I am trying to create a class that can set what is on the screen (for example, set a form to display what it has ever been) outside the midlet class ( Main)
So I thought that I needed to enter and change a variable Main display, but I came up with an error.
Here is the whole program:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Main extends MIDlet {
public Other othr = new Other(this);
public Display display = Display.getDisplay(this);
public void startApp() {
display.setCurrent(othr);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
import javax.microedition.lcdui.*;
public class Other extends Canvas{
Form a = new Form("a");
public TextEdit(Main mc){
mc.display.getDisplay(mc).setCurrent(a);
}
protected void paint(Graphics g) {
}
}
And I always get the error message "Application unexpectedly left."
I also tried replacing mc.display.getDisplay(mc).setCurrent(a);with Display.getDisplay(mc).setCurrent(a);, then the error is not displayed, but form a is not displayed at all.
This is probably a stupid mistake, but I lost
What can I do?
source
share