Advertisement
Guest User

bg

a guest
Apr 16th, 2013
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.74 KB | None | 0 0
  1. package titlescreenbeta;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.Insets;
  5. import javax.swing.Box;
  6. import javax.swing.BoxLayout;
  7. import javax.swing.ButtonGroup;
  8. import javax.swing.ImageIcon;
  9. import javax.swing.JButton;
  10. import javax.swing.JFrame;
  11. import javax.swing.JLabel;
  12. import javax.swing.JPanel;
  13. import javax.swing.JRadioButton;
  14. import javax.swing.SwingUtilities;
  15. import javax.swing.UIManager;
  16. import javax.swing.border.EmptyBorder;
  17.  
  18. public class TitleScreenBeta extends JFrame {
  19.  
  20.     public TitleScreenBeta() {
  21.  
  22.         initUI();
  23.     }
  24.  
  25.     public final void initUI() {
  26.        
  27.         try {
  28.             UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  29.         } catch (Exception e) {
  30.         }
  31.  
  32.         JPanel panel = new JPanel();
  33.         panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
  34.        
  35.         panel.setBorder(new EmptyBorder(new Insets(90, 155, 40, 60)));
  36.        
  37.         JButton NewGame = new JButton  ("New Game!");
  38.         JButton Highscore = new JButton("Highscore");
  39.         JButton Credits = new JButton  ("Credits");
  40.         JButton Website = new JButton  ("Website");
  41.         JButton Exit = new JButton     ("Exit");
  42.  
  43.         panel.add(NewGame);
  44.         panel.add(Box.createRigidArea(new Dimension(0, 5)));
  45.         panel.add(Highscore);
  46.         panel.add(Box.createRigidArea(new Dimension(0, 5)));
  47.         panel.add(Credits);
  48.         panel.add(Box.createRigidArea(new Dimension(0, 5)));
  49.         panel.add(Website);
  50.         panel.add(Box.createRigidArea(new Dimension(0, 5)));
  51.         panel.add(Exit);
  52.        
  53.        
  54.         final ButtonGroup entreeGroup = new ButtonGroup();
  55.         JRadioButton radioButton;
  56.         panel.add(radioButton = new JRadioButton("Music1"));
  57.         radioButton.setActionCommand("Music1");
  58.         entreeGroup.add(radioButton);
  59.         panel.add(radioButton = new JRadioButton("Music2"));
  60.         radioButton.setActionCommand("Music2");
  61.         entreeGroup.add(radioButton);
  62.         panel.add(radioButton = new JRadioButton("No Music", true));
  63.         radioButton.setActionCommand("No Music");
  64.         entreeGroup.add(radioButton);
  65.  
  66.         add(panel);
  67.  
  68.         pack();
  69.  
  70.         setTitle("Title");
  71.         JLabel background = new JLabel(new ImageIcon("background.png"));
  72.     add(background);
  73.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  74.         setLocationRelativeTo(null);
  75.         setResizable(false);
  76.         setSize(400, 400);
  77.        
  78.     }
  79.  
  80.     public static void main(String[] args) {
  81.  
  82.         SwingUtilities.invokeLater(new Runnable() {
  83.  
  84.             public void run() {
  85.                 TitleScreenBeta ex = new TitleScreenBeta();
  86.                 ex.setVisible(true);
  87.             }
  88.         });
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement