I'm trying to draw an image to a panel, but am having problems with it not showing up. I know I'm creating/loading the image properly, but I have the feeling I'm not painting it right.
public class ImageGet extends JPanel{
public String file = null;
public ImageGet(String fileName){
super();
file = fileName;
setPreferredSiz e(new Dimension(300, 300));
}
public void paintComponent( Graphics comp){
Graphics2D comp2D = (Graphics2D)com p;
Image image = getToolkit().cr eateImage(file) ;
while(comp2D.dr awImage(image, 0, 0, null)){
System.out.prin tln("Displaying now.");
}
}
}
public class ImageGet extends JPanel{
public String file = null;
public ImageGet(String fileName){
super();
file = fileName;
setPreferredSiz e(new Dimension(300, 300));
}
public void paintComponent( Graphics comp){
Graphics2D comp2D = (Graphics2D)com p;
Image image = getToolkit().cr eateImage(file) ;
while(comp2D.dr awImage(image, 0, 0, null)){
System.out.prin tln("Displaying now.");
}
}
}
Comment