Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.GridLayout;
- import javax.swing.JComboBox;
- import javax.swing.JPanel;
- public class StartScreen extends javax.swing.JFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- *
- */
- public StartScreen() {
- setStartScreen();
- }
- private void setStartScreen(){
- //Window title.
- setTitle("Connect Four");
- setSize(300, 200);
- //Default close operation and center the window.
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setLocationRelativeTo(null);
- //Button Panel.
- buttonPanel = new javax.swing.JPanel();
- buttonPanel.setLayout(new GridLayout(4,3));
- buttonPanel.setBackground(new java.awt.Color(240, 180, 90));
- //Play buttons.
- playButton = new javax.swing.JButton();
- playButton.setFont(new java.awt.Font("Garamond", 1, 14));
- playButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
- playButton.setText("PLAY");
- //Difficulty settings drop down menu.
- String [] difficultySettings = {"Human", "EasyAI", "MediumAI" , "ExpertAI"};
- JComboBox difficultyList1 = new JComboBox(difficultySettings);
- JComboBox difficultyList2 = new JComboBox(difficultySettings);
- //Load Button.
- loadButton = new javax.swing.JButton();
- loadButton.setFont(new java.awt.Font("Garamond", 1, 14));
- loadButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
- loadButton.setText("LOAD");
- //Quit Button.
- quitButton = new javax.swing.JButton();
- quitButton.setText("QUIT");
- //Add the buttons to the button Panel.
- buttonPanel.add(playButton);
- buttonPanel.add(loadButton);
- buttonPanel.add(quitButton);
- buttonPanel.add(difficultyList1);
- buttonPanel.add(difficultyList2);
- buttonPanel.repaint();
- buttonPanel.setVisible(true);
- }
- public static void main(String args[]) {
- // Create and display the form
- java.awt.EventQueue.invokeLater(new Runnable(){
- public void run() {
- new StartScreen().setVisible(true);
- }
- });
- }
- private JComboBox difficultyList1;
- private JComboBox difficulatyList2;
- private String[] difficultySettings;
- private JPanel buttonPanel;
- private javax.swing.JButton playButton;
- private javax.swing.JButton loadButton;
- private javax.swing.JButton quitButton;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement