JME: How to get the complete screen in WHITE without buttons, etc etc

大兔子大兔子 提交于 2019-12-02 04:47:46
    public void startApp() 
        {
            f = new Form("Back Light On");


           d = Display.getDisplay(this);


           start = new Command("Turn On",Command.OK,0);
           stop = new Command("Turn Off",Command.OK,1);

           f.addCommand(start);
           f.setCommandListener(new Action());

    myCanvas = new MyCanvas();
     d.setCurrent(myCanvas);   
            myCanvas.repaint();

}

Now create a canvas and implement paint method like this:

  class MyCanvas extends Canvas {
            public void paint(Graphics g) {
                // create a 20x20 black square in the center

                // clear the screen first
                g.setColor(0xffffff);
                g.fillRect(0, 0, getWidth(), getHeight());

                g.setColor(0xffffff); // make sure it is white color

                // draw the square, <b>changed to rely on instance variables</b>
                <b>g.fillRect(x, y, getWidth(), getHeight());</b>
            }
        }

Use the javax.microedition.lcdui.Canvas instead of Form. This example can get you started

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!