Hi everyone,
Im trying to build a small frame that displays an image.
My problem is that in the paint(Graphics g)
method, the g.drawImage
is executed, but nothing is shown on my RLFrame.
Any thoughts / tips?
Thanks in advance.
Here's the code
public class RLFrame extends JFrame{
Image img;
public RLFrame(String title){
super("testing");
}
public void run(){
MediaTracker mt = new MediaTracker(this);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(400, 400);
this.img = Toolkit.getDefaultToolkit().getImage("maps/23bis.ppm");
mt.addImage(this.img, 1, 100, 100);
this.setVisible(true);
}
public void paint(Graphics g){
System.out.println("Paint");
if(img != null){
System.out.println("draw");
g.drawImage(img, 300, 300, this);
}
else
{
g.clearRect(0, 0, getSize().width, getSize().height);
}
}
}