Everything works except when I push run, it doesn't show the icon for the label in the JFrame. Does anyone know how to fix that?
public class Frame extends JFrame
{
private final int speed=5;
JLabel label;
ImageIcon icon;
public void create() {
this.setSize(240,228);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.addKeyListener(this);
this.setLayout(null);
icon=new ImageIcon("rocket.png");
label=new JLabel();
label.setBounds(0,0,100,100);
label.setIcon(icon);
this.add(label);
this.setVisible(true);
}
}
I've tried renaming the file, putting it in several different spots in the code, and even looked up a tutorial or two, but none of them helped.
Change this:
to: