Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import java.net.URISyntaxException;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- public class Mdam extends JFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- static JPanel imagePanel = new JPanel((LayoutManager) new FlowLayout(FlowLayout.LEFT));
- public Mdam() throws IOException, URISyntaxException {
- super("Background");
- setSize(800, 600);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- setLayout(new BorderLayout());
- BufferedImage img = ImageIO.read(new File(getClass().getResource("sunflower_800x600.jpg").toURI()));
- JLabel background = new JLabel(new ImageIcon(img));
- imagePanel.add(background);
- add(imagePanel);
- setVisible(true);
- }
- public static void main(String[] args) throws IOException, URISyntaxException {
- new Mdam();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement