Hi I am creating a small demo for a game I want to create. I want to have a picture of Mario on a black line. I have implemented the code below. The JFrame
does start and I see the black line at the bottom, however the picture of Mario does not appear. I am sure the answer is obvious but help would be appreciated. I have tried adding the label to a JPanel
but the result is the same.
package Game;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class world extends JFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
world w = new world();
}
public ImageIcon mario = new ImageIcon("D:\\Eclipse\\2DShooter\\Photos\\wall-jump.jpg");
public world() {
setTitle("Demo");
setSize(800, 480);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JLabel Mario = new JLabel();
Mario.setIcon(mario);
add(Mario);
setVisible(true);
}
public void paint(Graphics g){
g.setColor(Color.BLACK);
g.fillRect(0, 460, 800, 20);
}
}