Advertisement
enevlogiev

BackgroundLoader

Feb 1st, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.image.BufferedImage;
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.net.URISyntaxException;
  6.  
  7. import javax.imageio.ImageIO;
  8. import javax.swing.*;
  9.  
  10.  
  11. public class Mdam extends JFrame {
  12.  
  13.     /**
  14.      *
  15.      */
  16.     private static final long serialVersionUID = 1L;
  17.     static JPanel imagePanel =  new JPanel((LayoutManager) new FlowLayout(FlowLayout.LEFT));
  18.    
  19.     public Mdam() throws IOException, URISyntaxException {
  20.         super("Background");
  21.         setSize(800, 600);
  22.         setLocationRelativeTo(null);
  23.         setDefaultCloseOperation(EXIT_ON_CLOSE);
  24.         setLayout(new BorderLayout());
  25.         BufferedImage img = ImageIO.read(new File(getClass().getResource("sunflower_800x600.jpg").toURI()));
  26.         JLabel background = new JLabel(new ImageIcon(img));
  27.         imagePanel.add(background);
  28.         add(imagePanel);
  29.         setVisible(true);
  30.     }
  31.    
  32.     public static void main(String[] args) throws IOException, URISyntaxException {
  33.         new Mdam();
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement