James
unread,May 13, 2008, 7:43:04 PM5/13/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to microemulator-developers
I wrote a small example MIDlet that created a GameCanvas and draws a
box with an X through it.
For this demonstration, I was using the microemu from eclipse. What
I can't understand, is why when I use the re-sizable device, and I
enlarge the screen size of it, that my box won't paint beyond the
limits of the original screen area. What I am trying to accomplish,
is to get my box to draw to the newly sized screen. Shrinking the
screen is fine, enlarging it does not seem to work.
Maybe someone could explain this to me? Here is the code:
package org.zeromhz.midp;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class TestMidlet2 extends MIDlet {
protected void destroyApp(boolean unconditional) throws
MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
GameCanvas canvas = new GameCanvas(false) {
Graphics graphics;
{
setFullScreenMode(true);
graphics = getGraphics();
}
protected void sizeChanged(int w, int h) {
super.sizeChanged(w, h);
System.out.println("sizeChanged(" + w + ", " + h + ")");
graphics = getGraphics();
graphics.setClip(0, 0, w, h);
drawBox(graphics, w, h);
flushGraphics(0, 0, w, h);
}
void drawBox(Graphics g, int w, int h) {
graphics.setColor(0xffffff);
graphics.fillRect(0, 0, w - 1, h - 1);
graphics.setColor(0x000000);
graphics.drawRect(0, 0, w - 1, h - 1);
graphics.drawLine(0, 0, w - 1, h - 1);
graphics.drawLine(0, h - 1, w - 1, 0);
}
protected void showNotify() {
System.out.println("showNotify()");
}
};
Display.getDisplay(this).setCurrent(canvas);
}
}