[personal java] need help do not know what is teh problem drawing image

M

mchmiel

I ve written some code in WSDD compile it and run it under IDE works
fine without problems but if i run the app on S80 Nokia device
emulator it doeasn'y show the image.

Look at the code:

import java.awt.*;
import java.awt.event.*;

public class proba extends Frame {
private Image image;

public proba() {
this.setLayout(new GridLayout(3, 1));

Toolkit tk = Toolkit.getDefaultToolkit();

Image im = tk.createImage("reklama.gif");
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(im, 1);
try {
tracker.waitForID(1);

} catch (Exception e) {
e.printStackTrace();
}
CommercialCanvas cv = new CommercialCanvas(im);

cv.setSize(new Dimension(im.getWidth(null),im.getHeight(null)));
cv.setVisible(true);

add(cv);
cv.repaint();
pack();
show();
setVisible(true);


}

public static void main(String[] args) {


System.out.println("IDZIEMY");
new proba();
}
}

class CommercialCanvas extends Canvas {


private Image image;

public CommercialCanvas(Image image) {
this.image = image;
}


public void paint(Graphics g) {
g.drawImage(
image,
10,10,image.getWidth(this),image.getHeight(this),
this);


}




}

of course You have to provide the image caled reklama.gif :)

Mchmiel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top