Advertisement
Guest User

Untitled

a guest
May 24th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. import java.awt.GridLayout;
  2.  
  3. import javax.swing.JComboBox;
  4. import javax.swing.JPanel;
  5.  
  6. public class StartScreen extends javax.swing.JFrame  {
  7.     /**
  8.      *
  9.      */
  10.     private static final long serialVersionUID = 1L;
  11.  
  12.     /**
  13.      *
  14.      */
  15.    
  16.     public StartScreen() {
  17.         setStartScreen();
  18.     }
  19.    
  20.     private void setStartScreen(){
  21.         //Window title.
  22.         setTitle("Connect Four");
  23.         setSize(300, 200);
  24.         //Default close operation and center the window.
  25.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  26.         setLocationRelativeTo(null);
  27.         //Button Panel.
  28.         buttonPanel = new javax.swing.JPanel();
  29.         buttonPanel.setLayout(new GridLayout(4,3));
  30.         buttonPanel.setBackground(new java.awt.Color(240, 180, 90));
  31.         //Play buttons.
  32.         playButton = new javax.swing.JButton();
  33.         playButton.setFont(new java.awt.Font("Garamond", 1, 14));
  34.         playButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
  35.         playButton.setText("PLAY");
  36.        
  37.         //Difficulty settings drop down menu.
  38.         String [] difficultySettings = {"Human", "EasyAI", "MediumAI" , "ExpertAI"};
  39.         JComboBox difficultyList1 = new JComboBox(difficultySettings);
  40.         JComboBox difficultyList2 = new JComboBox(difficultySettings);
  41.        
  42.         //Load Button.
  43.         loadButton = new javax.swing.JButton();
  44.         loadButton.setFont(new java.awt.Font("Garamond", 1, 14));
  45.         loadButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
  46.         loadButton.setText("LOAD");
  47.        
  48.         //Quit Button.
  49.         quitButton = new javax.swing.JButton();
  50.         quitButton.setText("QUIT");
  51.        
  52.        
  53.         //Add the buttons to the button Panel.
  54.         buttonPanel.add(playButton);
  55.         buttonPanel.add(loadButton);
  56.         buttonPanel.add(quitButton);
  57.         buttonPanel.add(difficultyList1);
  58.         buttonPanel.add(difficultyList2);
  59.         buttonPanel.repaint();
  60.         buttonPanel.setVisible(true);
  61.        
  62.     }
  63.    
  64.    
  65.     public static void main(String args[]) {
  66.          
  67.            // Create and display the form
  68.            java.awt.EventQueue.invokeLater(new Runnable(){
  69.                public void run() {
  70.                  
  71.                    new StartScreen().setVisible(true);
  72.                }
  73.            });
  74.         }
  75.    
  76.    
  77.     private JComboBox difficultyList1;
  78.     private JComboBox difficulatyList2;
  79.     private String[] difficultySettings;
  80.     private JPanel buttonPanel;
  81.     private javax.swing.JButton playButton;
  82.     private javax.swing.JButton loadButton;
  83.     private javax.swing.JButton quitButton;
  84.    
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement