EDIT Solved: I just realized I'm stupid and should have used "this" instead of "null" in drawImage().
I'm trying to create a simple window that shows a picture I have created, but it won't show the image until I have resized the window. I'm guessing paint() isn't being called properly, but I don't know. Here is the code:
import java.awt.*; import javax.swing.*; public class start extends JFrame{ public static void main(String[] args) { new start(); } private String filename = "C:\\item.gif"; private Image i = Toolkit.getDefaultToolkit().getImage(filename); public start() { setSize(400, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void paint(Graphics g) { g.drawImage(i, 50, 50, null); } }
Note that this code works fine if I draw something other than an image(i.e. fillOval())