Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package main;
- /**
- *
- * @author markjasongalang
- */
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.GridLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.Random;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- class TicTacToe implements ActionListener {
- Random random = new Random();
- JFrame frame = new JFrame();
- JPanel title_panel = new JPanel();
- JPanel button_panel = new JPanel();
- JLabel textfield = new JLabel();
- JButton[] buttons = new JButton[9];
- boolean player1_turn;
- boolean player2_turn;
- TicTacToe() {
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(800, 800);
- frame.getContentPane().setBackground(new Color(50, 50, 50));
- frame.setLayout(new BorderLayout());
- frame.setVisible(true);
- textfield.setBackground(new Color(25, 25, 25));
- textfield.setForeground(new Color(25, 255, 0));
- textfield.setFont(new Font("Arial", Font.BOLD, 75));
- textfield.setHorizontalAlignment(JLabel.CENTER);
- textfield.setText("Tic-Tac-Toe");
- textfield.setOpaque(true);
- title_panel.setLayout(new BorderLayout());
- title_panel.setBounds(0, 0, 800, 100);
- button_panel.setLayout(new GridLayout(3, 3));
- button_panel.setBackground(new Color(150, 150, 150));
- for (int i = 0; i < 9; i++) {
- buttons[i] = new JButton();
- button_panel.add(buttons[i]);
- buttons[i].setFont(new Font("Arial", Font.BOLD, 120));
- buttons[i].setFocusable(false);
- buttons[i].addActionListener(this);
- }
- title_panel.add(textfield);
- frame.add(title_panel, BorderLayout.NORTH);
- frame.add(button_panel);
- }
- public void actionPerformed(ActionEvent e) {
- }
- }
- public class Main {
- public static void main(String[] args) {
- TicTacToe game = new TicTacToe();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment