Skip to main content

accessing form object..

1 reply [Last post]
cutenik73
Offline
Joined: 2008-12-18

Hi.Is it possible to access current executing form object..?if yes..how can do that..

Regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sfitzjava
Offline
Joined: 2003-06-15

It sounds like what you want is to get access to the form that has been set current on the display object.

So you have done something like this in your startApp() method.
Form f = new Form("");
Display.getDisplay(this).setCurrent(f);

And maybe in the command listener you want to access the Form so you would do something like this:

Form curFrame = (Frame) Display.getDisplay(this).getCurrent();

This assumes that the MIDlet is the commandlistener, or you could have a singleton in your MIDlet so that you would have something like this in the MIDlet class.

public class MyApp extends MIDlet
{
public static final MIDlet self;
public MyApp() { self = this; }
}

Then the line would read:
Form curFrame = (Frame) Display.getDisplay(MyApp.self).getCurrent();

-Shawn