Displaying info in a non-MIDlet class

Hi,

I have a class which doesn't extend MIDlet class, and i would like to print some info on the screen (not on the standard output), but in that class i don't have references to the MIDlet which is executing it, nor references to that MIDlet's display. I know this sounds a little weird, but i don't have control of the MIDlet that is executing my code because it is some kind of platform that starts executing my code by itself.

I thought that if my class extended MIDlet class, i should be able to show an alert message (that's what i am trying, in fact), but it didn't work (probably because that MIDlet is never started, its code is executed instead).

My code looks like:

publicclass Viewextends MIDlet{

private Alert messages;

View(){

}

publicvoid writeMessage(String message){

messages =new Alert("Agent Contractor");

messages.setTimeout(Alert.FOREVER);

messages.setString(message);

messages.setType(AlertType.INFO);

Display.getDisplay(this).setCurrent(messages);

// messages.IsShown() returns false

}

publicvoid destroyApp(boolean o){}

publicvoid pauseApp(){}

publicvoid startApp(){}

}

IsShown returns false, so i think this is not working :)

So, is there a way of showing some messages on the phone's display without knowing the Display reference nor the MIDlet reference? Maybe should i try to get my MIDlet reference? but how?

I'm using J2MEWT, and the DefaultColorPhone emulator.

Thanks in advance,

David.

[2490 byte] By [nemov] at [2007-9-26 13:03:47]
# 1

Cannot seem to find anything. Is there any way that your class could be passed a reference to the calling MIDlet. Then you would be in a better position to display information. OR, does it have to write info top the screen? Is writing to a record store an option?

Maybe Alan can reply with the official Sun position.

d1camero at 2007-7-2 12:56:53 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

Thanks for your reply, but i finally solved it. I found a way of getting a reference to my MIDlet, so i had the control of its display.

Maybe it could be a good idea having some classes to write to the cellular's screen without being a MIDlet, like System.out.* classes in traditional Java.

See you.

David.

nemov at 2007-7-2 12:56:53 > top of Java-index,Java Mobility Forums,Java ME Technologies...