/* * BoxTextCanvas.java * * Created on 17 กันยายน 2546, 16:07 น. */ import javax.microedition.lcdui.*; /** * * @author suppakit * @version */ public class BoxTextCanvas extends Canvas { private Font mFont; public BoxTextCanvas(){ mFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_LARGE); } public void paint(Graphics g) { int w = getWidth(); int h = getHeight(); g.setColor(255,255,255); g.fillRect(0,0,w,h); g.setColor(0,0,0); String s = "dolce"; int stringWidth = mFont.stringWidth(s); int stringHeight = mFont.getHeight(); int x = (w-stringWidth)/2; int y = h/2; g.setFont(mFont); g.drawString(s, x, y, Graphics.TOP|Graphics.LEFT); g.drawRect(x, y, stringWidth, stringHeight); } }