Hi, this thing is really pissing me off... if anyone knows what I'm doing wrong could
you lend me a hand?
thanks :)
Scott
Problem:
I have a JPanel that ONLY draws the image if I resize or maximize it's Parent JFrame.
---
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class Example extends JPanel {
private Image im;
public Example(Image img) {
super();
im = img;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
System.out.println("paintComponent called");
if ((im != null) && isVisible()) {
System.out.println("Print passed");
g.drawImage(im,100,100,null);
}
}
public static void main(String[] args) {
JFrame j = new JFrame("Testing");
// Replace "Hlpbell.gif" with any image file in the same dir. as ur
// .class file
Image img = Toolkit.getDefaultToolkit().getImage("Hlpbell.gif");
MediaTracker tracker = new MediaTracker(j);
tracker.addImage(img, 0);
try {tracker.waitForID(0);}
catch (InterruptedException e) {}
Example e = new Example(img);
j.getContentPane().add(e);
j.setVisible(true);
j.setSize(800,600);
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".