Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Connect_4;
- import java.awt.GridLayout;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.GroupLayout;
- import javax.swing.GroupLayout.Alignment;
- import javax.swing.LayoutStyle.ComponentPlacement;
- import java.awt.Color;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import java.awt.BorderLayout;
- public class StartScreen extends javax.swing.JFrame {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- *
- */
- public StartScreen() {
- setStartScreen();
- }
- private void setStartScreen(){
- GameController g = GameController.getInstance();
- //Window title.
- setTitle("Connect Four");
- setSize(436, 301);
- //Default close operation and center the window.
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setLocationRelativeTo(null);
- //Button Panel.
- buttonPanel = new javax.swing.JPanel();
- buttonPanel.setBackground(Color.BLACK);
- //Play button.
- getContentPane().add(buttonPanel, BorderLayout.EAST);
- playButton = new javax.swing.JButton();
- playButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- GameGUI frame = new GameGUI();
- frame.setVisible(true);
- frame.setTitle("CONNECT 4");
- frame.setResizable(false);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- });
- playButton.setForeground(Color.LIGHT_GRAY);
- playButton.setBackground(Color.LIGHT_GRAY);
- 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" };
- JComboBox difficultyList1 = new JComboBox(difficultySettings);
- JComboBox difficultyList2 = new JComboBox(difficultySettings);
- //Difficulty List 1.
- difficultyList1.setForeground(Color.LIGHT_GRAY);
- difficultyList1.setBackground(Color.BLACK);
- difficultyList1.setFont(new java.awt.Font("Garamond", 1, 14));
- difficultyList1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
- //Difficulty List 2
- difficultyList2.setForeground(Color.LIGHT_GRAY);
- difficultyList2.setBackground(Color.BLACK);
- difficultyList2.setFont(new java.awt.Font("Garamond", 1, 14));
- difficultyList2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
- //Load Button.
- loadButton = new javax.swing.JButton();
- loadButton.setForeground(Color.LIGHT_GRAY);
- loadButton.setBackground(Color.LIGHT_GRAY);
- 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.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- });
- quitButton.setForeground(Color.LIGHT_GRAY);
- quitButton.setBackground(Color.LIGHT_GRAY);
- quitButton.setFont(new java.awt.Font("Garamond", 1, 14));
- quitButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
- quitButton.setText("QUIT");
- GroupLayout gl_buttonPanel = new GroupLayout(buttonPanel);
- gl_buttonPanel.setHorizontalGroup(
- gl_buttonPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_buttonPanel.createSequentialGroup()
- .addContainerGap(119, Short.MAX_VALUE)
- .addGroup(gl_buttonPanel.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_buttonPanel.createSequentialGroup()
- .addComponent(difficultyList2, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
- .addGap(58)
- .addComponent(difficultyList1, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
- .addGap(90))
- .addGroup(gl_buttonPanel.createSequentialGroup()
- .addGroup(gl_buttonPanel.createParallelGroup(Alignment.LEADING)
- .addComponent(loadButton, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
- .addComponent(playButton, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE))
- .addGap(152))
- .addGroup(gl_buttonPanel.createSequentialGroup()
- .addComponent(quitButton, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
- .addGap(151))))
- );
- gl_buttonPanel.setVerticalGroup(
- gl_buttonPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_buttonPanel.createSequentialGroup()
- .addGap(21)
- .addComponent(playButton, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(loadButton, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addGroup(gl_buttonPanel.createParallelGroup(Alignment.BASELINE)
- .addComponent(difficultyList2, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
- .addComponent(difficultyList1, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE))
- .addGap(18)
- .addComponent(quitButton, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(47, Short.MAX_VALUE))
- );
- buttonPanel.setLayout(gl_buttonPanel);
- 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