import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
public class Exec extends MIDlet {
private Display display;
public Exec() {
display = Display.getDisplay(this);
}
public void startApp() {
display.setCurrent(new DrawPanel());
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
class DrawPanel extends Canvas {
public void paint(Graphics g) {
String str = "NIIT 欢迎你";
g.setColor(0, 0, 0);
Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
Font.SIZE_LARGE);
g.setFont(font);
int fontWidth = font.stringWidth(str);
int fontHeight = font.getHeight();
g.drawString(str, getWidth() / 2 - fontWidth / 2, getHeight() / 2
- fontHeight / 2, Graphics.TOP | Graphics.LEFT);
}
}
[此贴子已经被作者于2010-12-12 18:34:09编辑过]