Hi guys, I just started messing around with Java graphics today. I'm a total n00b to this so my code is really messy. The problem with the following code is that when the application loads up, the image is not displayed until I maximize the screen. Why is this happening and how can I fix it?
CODE
import javax.imageio.*;
import javax.swing.*;
import java.awt.image.*;
import java.io.*;
import java.awt.*;
public class LoadImg extends Component
{
BufferedImage img = null;
public void paint(Graphics g)
{
g.drawImage(img, 0, 0, null);
}
public LoadImg() throws IOException
{
//load image from local directory
img = ImageIO.read(new File("leaf1.gif"));
}
public static void main(String[] crap) throws IOException
{
//create da frame
JFrame frame = new JFrame();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(0,0,600,600);
frame.add(new LoadImg());
}
}//end LoadImg