Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package flags;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.Box;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- public class Game extends JPanel {
- private static final long serialVersionUID = 1L;
- public static void setGUI() {
- JFrame start_screen = new JFrame("Flags App");
- // Image is 400x400px
- start_screen.add(new JLabel(new ImageIcon("res/rsz_planet_earth.jpg")), BorderLayout.NORTH);
- // JButtons
- Box box = Box.createVerticalBox();
- start_screen.getContentPane().add(box, BorderLayout.CENTER);
- JButton button = new JButton("Start");
- button.setBackground(Color.green);
- JButton button2 = new JButton("Help");
- button2.setBackground(Color.red);
- JButton button3 = new JButton("Info");
- button3.setBackground(Color.cyan);
- button.setAlignmentX(Component.CENTER_ALIGNMENT);
- button2.setAlignmentX(Component.CENTER_ALIGNMENT);
- button3.setAlignmentX(Component.CENTER_ALIGNMENT);
- button.setPreferredSize(new Dimension(66,66));
- button2.setPreferredSize(new Dimension(66,66));
- button3.setPreferredSize(new Dimension(66,66));
- box.add(button);
- box.add(button2);
- box.add(button3);
- final int WIDTH = 400;
- final int HEIGHT = 600;
- // Window
- start_screen.setSize(new Dimension(WIDTH, HEIGHT));
- start_screen.setLocationRelativeTo(null);
- start_screen.setResizable(true);
- start_screen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- start_screen.setVisible(true);
- }
- public static void main(String[] args) {
- setGUI();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement