#Why no button show up

1 messages · Page 1 of 1 (latest)

twilit gate
#

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.*;

public class TicTacToe {
int boardWith = 600;
int boardHeight = 650;

JFrame frame = new JFrame("Tic Tac Toe");
JLabel textLable = new JLabel();
JPanel textPanel = new JPanel();
JPanel boardPanel = new JPanel();

JButton[][] board = new JButton[3][3];
String playerX = "X";
String playerO = "O";
String currentPlayer = playerX;

TicTacToe() {
    frame.setTitle("Tic Tac Toe");
    frame.setSize(boardWith, boardHeight);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
    frame.setLayout(new BorderLayout());

    textLable.setBackground(Color.darkGray);
    textLable.setForeground(Color.white);
    textLable.setFont(new Font("Arial", Font.BOLD, 50));
    textLable.setHorizontalAlignment(JLabel.CENTER);
    textLable.setText("Tic Tac Toe");
    textLable.setOpaque(true);

    textPanel.setLayout(new BorderLayout());
    textPanel.add(textLable);
    frame.add(textPanel, BorderLayout.NORTH);
    
    boardPanel.setLayout(new GridLayout(3, 3));
    boardPanel.setBackground(Color.darkGray);
    frame.add(boardPanel);

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            board[i][j] = new JButton();
            board[i][j].setFont(new Font("Arial", Font.BOLD, 120));
            board[i][j].setFocusable(false);
            board[i][j].setBackground(Color.white);
            board[i][j].setForeground(Color.black);
            board[i][j].setBorderPainted(false);
            boardPanel.add(board[i][j]);
        }
    }
}

}

river windBOT
#

<@&987246452180930620> please have a look, thanks.