In J2ME to create the Display class object we use
private Display d;
d=Display.getDisplay(this);
What is this
as parameter?
I know this refers to the current instance but when I write the following I get errors
d=Display.getDisplay(new MyClassName());
When I saw in book the method was written like below
static Display getDisplay(MIDlet midlet)
So then I tried this
MIDlet m;
d=Display.getDisplay(m);
But I am getting errors and I cannot even pass new MIDlet()
as parameter since it's an abstract class.
As Android says, this
in d=Display.getDisplay(this); refers to your MIDlet.
But when you write the following you get errors
d=Display.getDisplay(new MyClassName());
It's because you try to create MIDlet by it's constructor. You would to see MIDlet doc:
protected MIDlet() Protected constructor for subclasses. The application management software is responsible for creating MIDlets and creation of MIDlets is restricted. MIDlets should not attempt to create other MIDlets. Throws: SecurityException - unless the application management software is creating the MIDlet.