CalcCanvas.java~1~
上传用户:hmzjsh
上传日期:2009-12-31
资源大小:5k
文件大小:1k
- package my.calc;
- import com.nokia.mid.ui.FullCanvas;
- import javax.microedition.lcdui.*;
- public class CalcCanvas extends FullCanvas{
- /**退出按钮*/
- private Command cmdExit;
- /**标题*/
- private String title = "Calculator";
- /**字体*/
- private Font f;
- /**显示的数字*/
- private int result = 0;
- /**焦点编号*/
- private int num = 0;
- /**焦点图片的坐标*/
- private int x = 0;
- private int y = 0;
- /**默认构造方法*/
- public CalcCanvas() {}
- public void paint(Graphics g) {
- f = g.getFont();
- //绘制标题
- g.drawString(title,getWidth() / 2,f.getHeight() / 2,Graphics.TOP|Graphics.HCENTER);
- //绘制文本框
- g.drawRect(3,24,172,20);
- //绘制数字
- String temp = Integer.toString(result);
- g.drawString(temp,getWidth() - temp.length() / 2 - 3,30,Graphics.TOP|Graphics.RIGHT);
- //绘制面板
- }
- }