@@ -0,0 +1,2149 @@
+/*%0A   Programmer: Kristoffer Larson%0A   Date: January 30, 2014%0A   %0A   Description: Loads in an image saved in the same folder%0A      and places it in the panel, to be displayed. %0A      First creates the button and then places the image%0A      icon. Modified from GUI_Frame.%0A*/%0A%0Aimport java.awt.Graphics;%0Aimport java.awt.image.BufferedImage;%0Aimport java.awt.event.ActionEvent;%0Aimport java.awt.event.ActionListener;%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Aimport javax.imageio.ImageIO;%0Aimport javax.swing.JFrame;%0Aimport javax.swing.JPanel;%0Aimport javax.swing.JLabel;%0Aimport javax.swing.*;%0A%0Apublic class GUI_Frame2 extends JPanel %7B%0A%0A   private JFrame frame;%0A   private JPanel panel;%0A   private JButton button;%0A   private BufferedImage img;%0A   private final String IMAGE = %22spaceship-space-city-future-clouds.jpg%22; //Image file name%0A%0A   public GUI_Frame2()%7B%0A      frame = new JFrame();%0A      frame.setSize(400,400);%0A      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A        %0A      loadImage();%0A      panel = new JPanel();  %0A       %0A      JLabel picLabel = new JLabel(new ImageIcon(img));%0A      %0A       %0A      button = new JButton(%22Press Me%22);%0A      button.addActionListener(%0A            new ActionListener()%7B%0A            %0A               public void actionPerformed(ActionEvent e)%7B%0A                  JOptionPane.showMessageDialog(null, %22You died! Try again%22);%0A                  System.exit(-1);%0A               %7D%0A            %7D);%0A   %0A      panel.add(button); %0A      panel.add(picLabel);%0A      frame.add(panel);%0A      frame.setVisible(true);%0A   %7D%0A   %0A   public GUI_Frame2(BufferedImage img) %7B%0A      this.img = img;%0A   %7D%0A   %0A   @Override%0A   protected void paintComponent(Graphics g) %7B //Paint the image on the frame%0A      super.paintComponent(g);%0A      if (img != null) %7B%0A         g.drawImage(img, 0, 0, this);%0A      %7D%0A   %7D%0A   %0A   public void loadImage() %7B //Load image file in%0A      try %7B%0A         img = ImageIO.read(new File(IMAGE));%0A      %7D %0A      catch (IOException e) %7B%0A         e.printStackTrace();%0A         System.exit(-1);%0A      %7D%0A   %7D%0A   %0A   public static void main(String%5B%5D args) %7B%0A      GUI_Frame2 test = new GUI_Frame2();%0A   %7D%0A%7D%0A

Create GUI_Frame2.java