import java.awt.*; import java.io.*; import javax.swing.*; import javax.imageio.*; public class ImageGui { private Image myImage; public static void main(String[] args) { ImageGui gui = new ImageGui(); JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout(5,5)); frame.getContentPane().setBackground(Color.WHITE); frame.getContentPane().add(new Label("this is an imported image"), BorderLayout.NORTH); frame.setSize(670,570); frame.setTitle("Mets game 15 Sept. 2007"); try { gui.myImage = ImageIO.read(new File("mets-game-15sep2007.jpg")); } catch(IOException exp) { System.out.println("Could not read the image file!"); } JPanel panel = new JPanel(){ public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.drawImage(gui.myImage, 10, 10, this); } }; frame.getContentPane().add(panel, BorderLayout.CENTER); frame.setVisible(true); } }