ConnectFour

/** * Connect Four Java * GUI version of Connect Four * Zaid Omer * Forrest Yuan * Dec. 18, 2017 */ import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.Image.*; import javax.imageio.ImageIO; import java.util.Scanner; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.JPanel; public class connectFour extends JFrame implements ActionListener { JLabel mainMenu = new JLabel(new ImageIcon("mainMenu.png")); String [][] position = new String [6][7]; JButton okButton = new JButton ("OK"); JLabel player1Label = new JLabel("Player 1:", JLabel.RIGHT); JLabel player2Label = new JLabel("Player 2:", JLabel.RIGHT); JLabel nameInstructions = new JLabel("Please enter your names", JLabel.RIGHT); JPanel pan1 = new JPanel(); JPanel pan2 = new JPanel(); JTextField player1Name = new JTextField(20); JTextField player2Name = new JTextField(20); public connectFour() { setTitle ("Connect Four"); setSize (975, 705); GridLayout frame = new GridLayout(); setLayout (frame); //contentPane.setBackgroundImage(bgImage); //-------- Set up the Panel 1 ---------------------------- BoxLayout box1 = new BoxLayout(pan1, BoxLayout.Y_AXIS); pan1.setLayout (box1); pan1.setBackground(Color.blue); okButton.addActionListener(this); // pan1.add(player1Label); // pan1.add(player1Name); // pan1.add(player2Label); // pan1.add(player2Name); // pan1.add(okButton); // pan1.add(nameInstructions); pan1.add(mainMenu); add(pan1); //------- set the Frame so the user can see it -------------- setVisible(true); } public void actionPerformed(ActionEvent event) { } public static void main(String[] args)throws Exception { Scanner input = new Scanner(System.in); System.out.println("Welcome to the Connect Four Game!"); new connectFour(); input.close(); } }
The game!

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.