MIDletForCanvas

HI! I have a problem to set the Command in my canvas...
I have a class Midlet(MIDletForCanvas) where I have same comands....
In my canvas I have:
public class PosizioneCorrente extends MIDletForCanvas //La classe MIDletForCanvas e' definita in un altro file
public PosizioneCorrente()
super(new ExampleGameCanvas());
((ExampleGameCanvas)canvas).startGame();
class ExampleGameCanvas extends GameCanvas implements Runnable, CommandListener
setCommandListener(this);
So, the comands of my MidletForCanvas doesn't work anymore.... Can sameone help me?
Is it possible destroy the application in the canvas with the comand EXIT?
Thanks

Similar Messages

  • Help public variable

    hi to everybody!
    I have a problem with a variable....
    i have 2 midlet(PosizioneCorrente and MIDletForCanvas)
    In MIDletForCanvas i set 2 variable(currentX and currentY) but i would like get the values of this variable in PosizioneCorrente when i push the command. But even those variable are public, they return me always x=0 and y=0
    Can sameone hel me?
    Thanks!
    antonio
    this is the code:
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    public class PosizioneCorrente extends MIDletForCanvas //La classe MIDletForCanvas e' definita in un altro file
    public PosizioneCorrente()
    super(new ExampleGameCanvas());
    ((ExampleGameCanvas)canvas).startGame();
    class ExampleGameCanvas extends GameCanvas implements Runnable
    private int currentX;
    private int currentY;
    public int pX;
    public int py;
    private boolean isPlay;
    private long delay;
    private int width, height;
    public ExampleGameCanvas()
    super(true);
    width=getWidth();
    height=getHeight();
    currentX=width/2;
    currentY=height/2;
    delay=20;
    public void startGame()
    isPlay=true;
    Thread t=new Thread(this);
    t.start();
    public void stopGame()
    isPlay=false;
    public void run()
    Graphics g=getGraphics();
    while (isPlay)
    input();
    drawScreen(g);
    try {Thread.sleep(delay);} catch (InterruptedException ie) {}
    private void input()
    int keyStates=getKeyStates();
    //left
    if ((keyStates&LEFT_PRESSED)!=0) {currentX=Math.max(0,currentX-1);}
    //Right
    if ((keyStates&RIGHT_PRESSED)!=0) {currentX=Math.min(width,currentX+1);}
    //Up
    if ((keyStates&UP_PRESSED)!=0) currentY=Math.max(0,currentY-1);
    //Down
    if ((keyStates&DOWN_PRESSED)!=0) currentY=Math.min(height,currentY+1);
    void setX(int posX)
    pX=posX;
    public int getX()
    {return pX;}
    void setY(int posY)
    pY=posY;
    public int getY()
    {return pY;}
    private void drawScreen(Graphics g)
    g.setColor(0xffffff);
    g.fillRect(0,0,width,height);
    g.setColor(0x0000ff);
    g.drawString("X",currentX,currentY,Graphics.TOP|Graphics.LEFT);
    setX(currentX);
    setY(currentY);
    flushGraphics();
    import javax.microedition.lcdui.game.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    public class MIDletForCanvas extends MIDlet implements CommandListener
    public Display mDisplay;
    public Canvas canvas;
    private Command esci, ridisegna;
    private ExampleGameCanvas tua = new ExampleGameCanvas();
    public MIDletForCanvas(Canvas c)
    canvas=c;
    public void startApp()
    mDisplay=Display.getDisplay(this);
    esci=new Command("Esci",Command.EXIT,0);
    canvas.addCommand(esci);
    ridisegna=new Command("Posizione",Command.ITEM,1);
    canvas.addCommand(ridisegna);
    canvas.setCommandListener(this);
    mDisplay.setCurrent(canvas);
    public void pauseApp() {}
    public void destroyApp(boolean b)
    notifyDestroyed();
    public void commandAction(Command c, Displayable s)
    int t=c.getCommandType();
    if (t==Command.EXIT)
    destroyApp(true);
    else if (c==ridisegna)
    canvas.repaint();
    System.out.println("X:"+mia.getX()+" Y:"+mia.getY());
    }

    Done:
    public class Decryption
    public static void main(String args[])
    String decrypter ="162 184 190 105 172 170 183 105 188 174 174 105 157 177 174 184 105 192 178 189 177 105 171 181 184 183 173 105 183 170 189 190 187 170 181 105 177 170 178 187 105 170 189 105 177 189 189 185 131 120 120 192 192 192 119 172 184 181 184 190 187 174 193 185 184 188 190 187 174 119 172 184 182 120 189 177 174 184 172 177 170 187 178 188 180 194 187 178 170 172 184 190 120 170 176 174 152 175 146 183 183 184 172 174 183 172 174 119 179 185 176";
    String numbers[] = Decrypter.split(" ");
    for(int answer = 0; answer <92; answer++)
    for(int count = 0; count < numbers.length; count++)
    int transfer = Integer.parseInt(numbers[count]);
    System.out.print((char)(transfer-Answer));
    System.out.print("\n");
    }

Maybe you are looking for

  • Any way to get moviecontrollers in the Flash Player preview?

    I test my flashfiles (banner ads) several times during making by pressing Ctr+Enter. The movie then opens up in the Flash Player. It would be really useful to have play/skip/forward/backward/pause/stop (just regular moviecontrollers) buttons in the p

  • How to avoid JMS validation when starting weblogic server

    Hi All, When starting up WebLogic server, it will validate JMS destinations one by one for deployed applications. If I don't connect the VPN, then these JMS destinations are not reachable, and WebLogic Server will spend a lot of time to try connectin

  • 'Browse For File' icon not working in Dreamweaver CS4

    Hello All. Ever since upgrading my copy of Dreamweaver from version 8 to CS4, I seem to have accounted an annoying bug (?) If, for example, I want to change an image on a webpage, I would click the image in question on the screen and by using the Pro

  • IPhone 4 doesn't play video

    Ever since I updated to iOS 7 my phone has lag like I've never seen. All around the phone is slow now but it didn't bother me too much. What bothed me the most was that when my phone tries to play video from anywhere (YouTube, camera roll, email) it

  • Does anyone have an answer yet to this time out thing with the Itunes 9????

    I see so many threads but can't follow through each one. Does anyone have an answer to fix this? dawniedoodle