|
@ -9,6 +9,7 @@ public class TicTacToeGame implements ActionListener { |
|
|
JPanel t_panel = new JPanel(); |
|
|
JPanel t_panel = new JPanel(); |
|
|
JPanel bt_panel = new JPanel(); |
|
|
JPanel bt_panel = new JPanel(); |
|
|
JLabel textfield = new JLabel(); |
|
|
JLabel textfield = new JLabel(); |
|
|
|
|
|
JButton[] bton = new JButton[9]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Creating class constructor |
|
|
// Creating class constructor |
|
@ -22,8 +23,8 @@ public class TicTacToeGame implements ActionListener { |
|
|
frame.setLayout(new BorderLayout()); |
|
|
frame.setLayout(new BorderLayout()); |
|
|
frame.setVisible(true); |
|
|
frame.setVisible(true); |
|
|
|
|
|
|
|
|
textfield.setBackground(new Color(0,0,0)); |
|
|
|
|
|
textfield.setForeground(new Color(255,0,0)); |
|
|
|
|
|
|
|
|
textfield.setBackground(new Color(0, 0, 250)); |
|
|
|
|
|
textfield.setForeground(new Color (100,100,255)); |
|
|
textfield.setFont(new Font("Serif", Font.BOLD, 25)); |
|
|
textfield.setFont(new Font("Serif", Font.BOLD, 25)); |
|
|
textfield.setHorizontalAlignment(JLabel.CENTER); |
|
|
textfield.setHorizontalAlignment(JLabel.CENTER); |
|
|
textfield.setText("Tic Tac Toe"); |
|
|
textfield.setText("Tic Tac Toe"); |
|
@ -34,7 +35,19 @@ public class TicTacToeGame implements ActionListener { |
|
|
|
|
|
|
|
|
bt_panel.setLayout(new GridLayout(3, 3)); |
|
|
bt_panel.setLayout(new GridLayout(3, 3)); |
|
|
bt_panel.setBackground(new Color(0, 0, 0)); |
|
|
bt_panel.setBackground(new Color(0, 0, 0)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 9; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
bton[i] = new JButton(); |
|
|
|
|
|
bt_panel.add(bton[i]); |
|
|
|
|
|
bton[i].setFont(new Font("Serif", Font.BOLD, 120)); |
|
|
|
|
|
bton[i].setFocusable(false); |
|
|
|
|
|
bton[i].addActionListener(this); |
|
|
|
|
|
bton[i].setBackground(Color.cyan); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
t_panel.add(textfield); |
|
|
|
|
|
frame.add(t_panel, BorderLayout.NORTH); |
|
|
|
|
|
frame.add(bt_panel); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|