Translating the steps above to Java code gives us this…
HelloWorldCanvas.java
importjavax.microedition.lcdui.Canvas;
importjavax.microedition.lcdui.Graphics;
public class HelloWorldCanvas extends Canvas {
protected void paint(Graphics g) {
g.setColor(0, 0, 0);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(255, 255, 255);
g.drawString("Hello World!", 20, 20, Graphics.LEFT | Graphics.BOTTOM);
}
}
No comments:
Post a Comment