当前位置: 网站首页 > JAVA > j2me

j2me学习笔记

时间:1970-1-1 08:33:31来源: j2me作者:admin 点击:0次 字体 [ С]

使用canvas实现数据过多时候的下拉

+ expand sourceview plaincopy to clipboardprint?
package ui;  
import java.util.Vector;  
import javax.microedition.lcdui.Canvas;  
import javax.microedition.lcdui.Font;  
import javax.microedition.lcdui.Graphics;  
public class MenuCanvas extends Canvas {  
    private int width;                          //屏幕宽度  
    private int height;                         //屏幕高度  
    private int fontHeight;                     //文本高度  
    private static int paddingHeight = 5;       //文本间隔高度  
    private String words = "经贸学院东";  
    private Vector vector = new Vector();  
    private int lineNumber = 0;                 //行号  
    private Font font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);  
    private int xxx;  
      
    public MenuCanvas() {  
        width = this.getWidth();  
        height = this.getHeight();  
        fontHeight = font.getHeight();  
        for (int i=0; i<20; i++) {  
            vector.addElement(words + i);  
        }  
        xxx = width / (fontHeight + paddingHeight);  
    }  
    protected void paint(Graphics g) {  
        g.setColor(255, 255, 255);  
        g.fillRect(0, 0, width, height);  
        int x = lineNumber;   

发表评论
验证码:
最新评论