0

Hai Friends,

Iam using canvas class in my J2ME progrm,it does show full screen view in mobile, i want to show j2Me form to full mobile screen, please help me for this problem.

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by peter_budo
0

Iam using Gamecanvas only but it does not displaying for full mobile screen.
my code is here

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import javax.microedition.midlet.*;

public class CanvasGame extends MIDlet{

    private Command back;
    private Display display;
    final SweepGame game = new SweepGame();

    public void startApp() {
        back = new Command("Back", Command.BACK, 0);
        game.start();
        game.addCommand(back);
        game.setCommandListener(new CommandListener(){
            public void commandAction(Command c, Displayable s) {
                game.stop();
                notifyDestroyed();
            }
        });
        display = Display.getDisplay(this);
        display.setCurrent(game);
    }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional) {}
}

class SweepGame extends GameCanvas implements Runnable {
    private boolean move;
    private int radius;
    private int diameter;
    private int interval;

    public SweepGame() {
        super(true);
        radius = 0;
        diameter = 10;
        interval = 0;
    }
    public void start() {
        move = true;
        Thread t = new Thread(this);
        t.start();
    }
    public void stop() {
        move = false;
    }
    public void render(Graphics g) {
        int width = getWidth();
        int height = getHeight();
        g.setColor(183,251,121);
        g.fillRect(0, 0, width - 1, height - 1);
        int x = diameter;
        int y = diameter;
        int w = width - diameter * 2;
        int h = height - diameter * 2;
        for (int i = 0; i < 17; i=i+2) {
            g.setColor(((17 - i) * 15 - 7),20,((17 - i) * 15 - 7));
            g.fillArc(x, y, w, h, radius + i * 10, 10);
            g.fillArc(x, y, w, h, (radius + 180) % 360 + i * 10, 10);
        }
    }
    public void run() {
        Graphics g = getGraphics();
        while (move) {
            radius = (radius + 1) % 360;
            render(g);
            flushGraphics();
            try {
                Thread.sleep(interval);
            }
            catch (InterruptedException ie) {}
        }
    }
}

Edited by Dani: Formatting fixed

0

Yeap, just add setFullScreenMode(true); to any Canvas class in declaration like bellow and you done

public SweepGame() {
        super(true);
        setFullScreenMode(true);
        radius = 0;
        diameter = 10;
        interval = 0;
    }

PS: Use of code tags with your post count should be one of MUST DO!

Edited by peter_budo: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.