Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.swing.BoxLayout;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- public class Field {
- public static void addComponentsToPane(Container pane) {
- pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
- BufferedImage myPicture = null;
- try {
- myPicture = ImageIO.read(new File("D:\\Software-University\\Field - Copy2.jpg"));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- JLabel picLabel = new JLabel(new ImageIcon(myPicture));
- pane.add(picLabel);
- }
- /*
- * Create the GUI and show it.
- */
- private static void createAndShowGUI() {
- //Create and set up the window.
- JFrame frame = new JFrame("Game frame");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- //Set up the content pane.
- addComponentsToPane(frame.getContentPane());
- //Display the window.
- frame.setSize(1005, 735);
- frame.setResizable(false);
- frame.setTitle("Pong");
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- }
- public static void main(String[] args) {
- //creating and showing this application's GUI.
- javax.swing.SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- createAndShowGUI();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment