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

后端 未结 2 1795
广开言路
广开言路 2021-01-24 07:10

Please have a look at the following code

First, Please note I am a 100% newbie to Java Mobile.

In here, I am making the light on and vibrate on when user click t

相关标签:
2条回答
  • 2021-01-24 07:40

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

    0 讨论(0)
  • 2021-01-24 07:58
        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>
                }
            }
    
    0 讨论(0)
提交回复
热议问题