📄 drawcanvas.java
字号:
/*
* DrawCanvas.java
*
* Copyright 2001 SkyArts. All Rights Reserved.
*/
import javax.microedition.lcdui.*;
/**
* 变换Font的种类来描绘的Canvas类
*
* @author Hideki Yonekawa
* @version 1.0
*/
class DrawCanvas extends Canvas {
/** 进行描绘的方法 */
protected void paint(Graphics g) {
//将背景涂白
g.setColor(0x00FFFFFF);
g.fillRect(0, 0, getWidth(), getHeight());
//将颜色指定为黑色
g.setColor(0x00000000);
int drawY = 0;
Font font = Font.getDefaultFont();
//以默认字体来描绘文字
g.drawString("Default", 0, drawY, Graphics.TOP|Graphics.LEFT);
//加上描绘Font高度的Y坐标
drawY = drawY + font.getHeight();
//取得Font,设定至Graphics
font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
g.setFont(font);
//以Proportional、Plain、Medium字体来描绘文字
g.drawString("Prop Plain Midium", 0, drawY, Graphics.TOP|Graphics.LEFT);
//加上描绘Font高度的Y坐标
drawY = drawY + font.getHeight();
//取得Font,设定至Graphics
font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
g.setFont(font);
//以Monospace、Bold、Large字体来描绘文字
g.drawString("Mono Bold Large", 0, drawY, Graphics.TOP|Graphics.LEFT);
//加上描绘Font高度的Y坐标
drawY = drawY + font.getHeight();
//取得Font,设定至Graphics
font = Font.getFont(Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD | Font.STYLE_ITALIC,
Font.SIZE_MEDIUM);
g.setFont(font);
//以Proportional、Bold|Italic、Medium字体来描绘文字
g.drawString("Prop Bold|Italic Midium", 0, drawY, Graphics.TOP|Graphics.LEFT);
//加上描绘Font高度的Y坐标
drawY = drawY + font.getHeight();
//取得Font,设定至Graphics
font = Font.getFont(Font.FACE_SYSTEM,
Font.STYLE_BOLD | Font.STYLE_ITALIC | Font.STYLE_UNDERLINED,
Font.SIZE_SMALL);
g.setFont(font);
//System、Bold|Italic|Underline、Small字体来描绘文字
g.drawString("System Bold|Italic|Under Small", 0, drawY, Graphics.TOP|Graphics.LEFT);
//加上描绘Font高度的Y坐标
drawY = drawY + font.getHeight();
//取得Font,设定至Graphics
font = Font.getFont(Font.FACE_SYSTEM,
Font.STYLE_PLAIN | Font.STYLE_UNDERLINED,
Font.SIZE_MEDIUM);
g.setFont(font);
//以System、Plain|Underline、Medium字体来描绘文字
g.drawString("System Plain|Under Midium", 0, drawY, Graphics.TOP|Graphics.LEFT);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -