Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class TicTac {
- JPanel windowGame;
- Button[] squares = new Button[9];
- Button newGameButton;
- JLabel wonScore;
- JLabel loseScore;
- JLabel score;
- JPanel panel1;
- JPanel panel2;
- JPanel panel3;
- int emptySquaresLeft=9;
- int won = 0;
- int lose = 0;
- public void init() {
- JPanel windowGame = new JPanel();
- BorderLayout bl = new BorderLayout();
- windowGame.setLayout(bl);
- JLabel wonScore = new JLabel();
- JLabel loseScore = new JLabel();
- JPanel panel1 = new JPanel();
- windowGame.add("North", panel1);
- Button newGameButton = new Button();
- newGameButton.setBackground(Color.GREEN);
- wonScore = new JLabel ("Побед: 0");
- loseScore = new JLabel ("Поражений: 0");
- panel1.setLayout(bl);
- panel1.add(newGameButton);
- panel1.add(wonScore);
- panel1.add(loseScore);
- JLabel score = new JLabel ("Твой ход человек!");
- windowGame.add(score, "South");
- JPanel panel2 = new JPanel();
- windowGame.add("Center", panel2);
- Button[] squares = new Button[9];
- JFrame frame = new JFrame();
- frame.setContentPane(windowGame);
- frame.pack();
- frame.setVisible(true);
- TicTacEngine TicTacEngine = new TicTacEngine(this);
- for (int i=0; i<10; i++) {
- squares[i] = new Button (""+i);
- squares[i].addActionListener(TicTacEngine); /* Cant be resolved to a variable */
- squares[i].setBackground(Color.ORANGE);
- panel2.add(squares[i]);
- }
- }
- public static void main (String[] args) {
- TicTac TicTacGame = new TicTac();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement