MIDlet or Display as Parameter to Canvas Implementation

Go down

MIDlet or Display as Parameter to Canvas Implementation

Post  javafan on Wed Oct 10, 2007 2:56 am

hi all,

an implementation of a canvas definitly needs the display object.
well, i found 2 different way of implementation in the samples all over the web.

the first one uses a "Display" parameter. the data is then set active by the calling class.
Code:

public class SampleCanvas extends Canvas {

private Display display;

public SampleCanvas(Display display) {
this.display = display;
}

public void setData(...) {
...
}

...

}



other code uses the complete MIDlet as parameter.
the data will then get by a method in the MIDlet.

Code:
public class SampleCanvas extends Canvas {

private SampleMIDlet midlet;

public SampleCanvas(SampleMIDlet midlet) {
this.midlet = midlet;
}

protected void paint(Graphics arg0) {

... midlet.getData() ...

}

...

}
what kind of implementation is prefered by you - and why?
avatar
javafan

Posts : 11
Join date : 2007-09-11

View user profile

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum