fontcanvas.java
来自「《精通JAVA手机游戏与应用程序设计》随书光盘」· Java 代码 · 共 56 行
JAVA
56 行
package FontDemo;
import javax.microedition.lcdui.*;
class FontCanvas extends Canvas {
FontCanvas() {
}
void init() {
}
void destroy() {
}
protected void paint(Graphics g) {
g.setColor(0x001169ee);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
String title = "系统";
int height = 0;
int currentFace = Font.FACE_SYSTEM;
g.setColor(0x00ffffff);
g.drawString(title, 0, 0, Graphics.TOP|Graphics.LEFT);
height += g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,
Font.STYLE_PLAIN,
Font.SIZE_LARGE));
g.drawString("系统 常规 加大", 0, height, Graphics.TOP|Graphics.LEFT);
height += g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,
Font.STYLE_ITALIC,
Font.SIZE_LARGE));
g.drawString("系统 倾斜 加大", 0, height, Graphics.TOP|Graphics.LEFT);
height += g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,
Font.STYLE_BOLD,
Font.SIZE_LARGE));
g.drawString("系统 加粗 加大", 0, height, Graphics.TOP|Graphics.LEFT);
height += g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,
Font.STYLE_BOLD|Font.STYLE_ITALIC,
Font.SIZE_LARGE));
g.drawString("系统 加粗 倾斜 加大", 0, height, Graphics.TOP|Graphics.LEFT);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?