In the code d=Display.getDisplay(this);
, this refers to the Current Midlet. The Method getDisplay()
takes one midlet argument. Take the following simple example
public class MyMidlet extends Midlet
{
private Display display;
public MyMidlet()
{
display = Display.getDisplay(this); // Here this refers to the current class's Midlet
}
}
Now suppose you have normal class file like below,
public class MyClass
{
private Display display;
Midlet m;
public MyClass()
{
display = Display.getDisplay(m); // You can not do this directly.
}
}
if you want the above scenario then you might need to change your code some how like below,
suppose you have both the class in same package.
// Midlet Class
public class MyMidlet extends Midlet
{
private MyClass mycls;
public void myMethod ()
{
mycls = MyClass(this); // Passing Midlet reference to MyClass's constructor.
}
....
....
....
}
// another class file
public class MyClass
{
private Display display;
Midlet m;
public MyClass( Midlet m )
{
this.m = m;
display = Dispaly.getDisplay(m); // Now it will work
}
}