×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2004
    Location
    Portugal
    Posts
    5

    Drawing image problem (solved)

    Hi all.
    This runs fine on some emulators, but on sun's wtk21 emulator and on nokia 3650 all I get is a white screen.
    Any ideia how to do it right.
    A code snippet would help.
    TIA.

    public void paint(Graphics g) {
    g.setColor(255,255,255);
    g.fillRect(0, 0, canvas0.getWidth(), canvas0.getHeight());
    int x = 0;
    int y = 0;
    for(int i=0;i< 12;i++){
    for(int j=0;j<12;j++){
    switch(nBoard[i][j]) {
    case 1:
    g.drawImage(_$Images$yellow_png,x, y, Graphics.LEFT| Graphics.TOP);
    break;
    case 2:
    g.drawImage(_$Images$red_png,x, y, Graphics.LEFT| Graphics.TOP);
    break;
    case 3:
    g.drawImage(_$Images$blue_png,x, y, Graphics.LEFT| Graphics.TOP);
    break;
    case 4:
    g.drawImage(_$Images$purple_png,x, y, Graphics.LEFT| Graphics.TOP);
    break;
    case 5:
    g.drawImage(_$Images$green_png,x, y, Graphics.LEFT| Graphics.TOP);
    break;
    }
    x+=12;
    }
    y+=12;
    x = 0;
    }
    }
    Last edited by cmonteiro; 2004-10-26 at 15:37.

  2. #2
    Registered User
    Join Date
    Sep 2003
    Posts
    34
    try to comment the the 2nd line:
    g.fillRect(0, 0, canvas0.getWidth(), canvas0.getHeight());

    and replace it with the actual size of the screen
    g.fillRect(0,0,176,208);

    Let see whether it works or not.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Location
    Portugal
    Posts
    5
    I've tried that amongst many other things.
    Maneged to make it work by displaying a splash screen (another canvas) before setting this canvas the current display.
    Have no idea why.
    Thanks for reply.

Posting Permissions

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