CJCoding With Joseph
15free / daySign inCreate account

Mastering Java Swing

Adding the Game Board - STEP 3

Tic Tac Toe Game

Now let’s add the 9 buttons to the screen so players can click where they want to place an X or O.

To manage the buttons, we’ll create a private JButton array as a class variable to store them all:

 private JButton[] buttons;

We’ll also need to add the following imports at the top of the file to use fonts and layouts:

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in Mastering Java Swing.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.