×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Bangalore
    Posts
    117

    Switching between Canvases(Other than Softkey)

    Hello.............

    Is there any way For switching between canvases other that using(Softkeys or Commandlister)Something like Some event happens in one canvas and that will cause other canvas to be current display.



    Thanzx

    Chandu

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Helsinki.FI
    Posts
    112
    Hi,

    just try catching the desired event by comparing some variable, setting some flag, etc. in your Canvas1 loop and then setting the display to YOUR_DISPLAY.setCurrent(Canvas2); which put Canvas2 on screen. Calling repaint() on Canvas2 calls its paint() method and paints contents of the canvas on the screen.


    == Canvas1 ==

    import javax.microedition.lcdui.*;
    import com.nokia.mid.ui.*;

    class Canvas1 extends FullCanvas implements Runnable {
    ...
    private boolean goToCanvas2 = false;
    private FullCanvas c2 = null;
    ...

    Canvas1() {
    // Canvas1 initialization
    }

    run() {
    // implement your thread functionality here
    (if goToCanvas2 == true) {
    // stop threads here
    c2 = new Canvas2(this);
    display.setCurrent(c2);
    }
    ...
    }

    paint() {
    // paint method for Canvas1
    }

    }

    == Canvas2 ==

    import javax.microedition.lcdui.*;
    import com.nokia.mid.ui.*;

    class Canvas2 extends FullCanvas implements Runnable {
    ...
    private boolean goToCanvas1 = false;
    private FullCanvas c1 = null;
    ...

    Canvas2(FullCanvas fc) {
    // Canvas2 initialization
    c1 = fc;
    }

    run() {
    // implement your thread functionality here
    (if goToCanvas1 == true) {
    // stop threads here
    display.setCurrent(c1);
    }
    ...
    }

    paint() {
    // paint method for Canvas2
    }

    }


    Hope this quick sketch helps.

    Kind regards,
    Tinke / FN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •