📄 hintcanvas.java
字号:
package picturepuzzle;
import javax.microedition.lcdui.*;
/**
* 显示屏图原始图片的类
*/
public class HintCanvas extends Canvas {
private Image image;
private int posX , posY;
private int cWidth, cHeight;
public HintCanvas(Image image) {
super();
this.image = image;
cWidth = getWidth();
cHeight = getHeight();
posX = (cWidth - image.getWidth())/2;
posY = (cHeight - image.getHeight())/2;
}
public void paint(Graphics g) {
g.setColor(255 , 255 , 255);//paint a white background
g.fillRect(0 , 0 , cWidth , cHeight);
g.drawImage(image , posX , posY , Graphics.TOP | Graphics.LEFT);
g.setColor(0 , 0 , 255);//paint text in blue
g.setFont(Font.getFont(Font.FACE_MONOSPACE , Font.STYLE_BOLD , Font.SIZE_SMALL));
g.drawString("Original Image" , getWidth() / 2 , 0 , Graphics.HCENTER | Graphics.TOP);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -