sizeChanged and GameCanvas

4 views
Skip to first unread message

James

unread,
May 13, 2008, 7:43:04 PM5/13/08
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);
}
}


Bartek Teodorczyk

unread,
May 14, 2008, 9:08:35 AM5/14/08
to microemulato...@googlegroups.com
It should be fixed now in SVN trunk.

Regards,
Bartek

James

unread,
May 14, 2008, 11:58:00 AM5/14/08
to microemulator-developers
Hey thanks a lot.

I was wondering, how often do you publish snapshots to
http://www.pyx4me.com/maven2-snapshot ?

-James

On May 14, 7:08 am, "Bartek Teodorczyk" <bar...@barteo.net> wrote:
> It should be fixed now in SVN trunk.
>
> Regards,
> Bartek
>

Bartek Teodorczyk

unread,
May 14, 2008, 12:04:06 PM5/14/08
to microemulato...@googlegroups.com
Snapshot with today's changes will build during the night:
http://snapshot.microemu.org/microemulator/download/

Regards,
Bartek

Reply all
Reply to author
Forward
0 new messages