Hi,
I have made a simple window using the following code:
import java.awt.*; import javax.swing.*; class CreateWindow{ public static void main(String[]args){ //creating the window JFrame frame = new JFrame("My Window"); //make the program terminate when the window is closed frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); //set the window location frame.setLocationRelativeTo(null); //set the window size frame.setSize(400,200); //create a JLabel object (a graphical component) JLabel label = new JLabel("Hello"); //get ahold of the windows content pane and add the graphical component to it frame.getContentPane().add(label); //set the window to visible frame.setVisible(true); } }
Could you tell the simplest way to getting an image displayed in my window. I assumed I would add an image to the JLabel object, but I dont know how to do this.