hi guys.
i'm new to j2me .
do you have any idea what causes the problem with below code?
it's just example code in toolkit and i put in simple loop code there.
i thought that setCurrent adds SCREEN event and then that event is processed immediately (by other rendering thread?) if possible.
but program does not draw the screen when while statements are in there.
if I remove while statements, it works well and shows the "Test string" screen.
does it mean that draw is starting after executing startApp?
if then, how can I implement my event patching(something socket read) loop, and where is right place to put the loop?
of course, i can make event reading code with thread, but i guess event polling must be loop..
and what is excuting after startApp ends? i mean executing flow..just only event listener thread waits for event?
thanks in advance..and below is the code.
thank you =)
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet implements CommandListener
{
private Command exitCommand;
private Display display;
public HelloMIDlet()
{
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}
public void startApp()
{
TextBox t = new TextBox("Hello MIDlet", "Test string", 256, 0);
t.addCommand(exitCommand);
t.setCommandListener(this);
display.setCurrent(t);
while (true)// what i added.
{
// i wanna check some conditions(ex. socket reading), and then process it repeatedly.
System.out.println(".");
}
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable s)
{
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}