import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.MIDlet;
public class DrawImageGraphicsMIDlet extends MIDlet {
private Display display;
protected void startApp() {
Canvas canvas = new LineCanvas();
display = Display.getDisplay(this);
display.setCurrent(canvas);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
class LineCanvas extends Canvas {
public void paint(Graphics g) {
int width = getWidth();
int height = getHeight();
try {
Image image = Image.createImage("/h.png");
g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
} catch (IOException ex) {
g.setColor(0xffffff);
g.drawString("Failed to load image!", 0, 0, Graphics.TOP | Graphics.LEFT);
return;
}
}
}
|