Java 修改股票代码

Java 修改股票代码,java,blackberry,java-me,midp,Java,Blackberry,Java Me,Midp,我正在尝试修改下面的类,以便滚动文本出现在屏幕左下角绘制的“overlay.png”图像后面 我试着换衣服 final int screenWidth = Display.getWidth(); 到 但是没有起作用 我怎么能相信这个 谢谢 public class Ticker extends Field { String text; final int screenWidth = Display.getWidth(); int offset = scr

我正在尝试修改下面的类,以便滚动文本出现在屏幕左下角绘制的“overlay.png”图像后面

我试着换衣服

final int screenWidth = Display.getWidth();

但是没有起作用

我怎么能相信这个

谢谢

   public class Ticker extends Field {

        String text;
    final int screenWidth = Display.getWidth();
    int offset = screenWidth;
    Timer timer = new Timer();
    final int delay = 20;
    private Bitmap backgroundImage;

    public void setText(String text) {
        this.text = text;
    }

    public String getText() {
        return text;
    }

    public Ticker(String text) {
        this.text = text;
        backgroundImage = Constants.TICKER_BACKGROUND_IMAGE;
        final int width = Font.getDefault().getAdvance(text);
        TimerTask timerTask = new TimerTask() {
            public void run() {
                offset--;
                if (offset + width == 0) {
                    offset = screenWidth;
                }
                invalidate();
            }
        };
        timer.scheduleAtFixedRate(timerTask, delay, delay);
    }

    protected void layout(int width, int height) {
        int w = Display.getWidth();
        int h = Font.getDefault().getHeight();
        setExtent(w, h);

    }

    protected void paint(Graphics graphics) {


        graphics.drawBitmap( 0, 0, backgroundImage.getWidth(), backgroundImage.getHeight(), backgroundImage, 0, 0 );
        Bitmap b = Bitmap.getBitmapResource("overlay.png");
        graphics.drawBitmap( 0, 0, b.getWidth(), b.getHeight(), b, 0, 0 );

        graphics.setColor(Color.WHITE);
        graphics.drawText(text, offset, 0);
    }


}

尝试按以下方式修改绘制方法:

protected void paint(Graphics graphics) {


    graphics.drawBitmap( 0, 0, backgroundImage.getWidth(), backgroundImage.getHeight(), backgroundImage, 0, 0 );

    graphics.setColor(Color.WHITE);
    graphics.drawText(text, offset, 0);

    Bitmap b = Bitmap.getBitmapResource("overlay.png");
    graphics.drawBitmap( 0, 0, b.getWidth(), b.getHeight(), b, 0, 0 );

}

不要使用自动售票机!它们违背了我能想到的每一个好的UI设计原则!在这种情况下,我必须使用一个。
protected void paint(Graphics graphics) {


    graphics.drawBitmap( 0, 0, backgroundImage.getWidth(), backgroundImage.getHeight(), backgroundImage, 0, 0 );

    graphics.setColor(Color.WHITE);
    graphics.drawText(text, offset, 0);

    Bitmap b = Bitmap.getBitmapResource("overlay.png");
    graphics.drawBitmap( 0, 0, b.getWidth(), b.getHeight(), b, 0, 0 );

}