Swing & Event-Driven Programming

This project is designed to introduce you to Java Swing libraries and Event-Driven Programming, and to give you practice modifying existing code (yours).

In a previous project, you designed and implemented a TicTacToe game. Input was from the keyboard, and output was to the console. Now you want to change the game so that it uses a GUI instead of the keyboard. Players will click buttons in a window rather than type numbers on the console. In your comments, you must indicate what you had to change in your existing code to make it work with the GUI.

A basic GUI and requirements are given below. You may change the colors if you wish, and use a different organization if you prefer, but the basic elements shown below must function correctly your finished project.

The status bar is a textfield, and should always reflect the current status, such as "Turn: Player X", "Turn: Player O", or "Winner X", etc. This text field in not editable by the game players. If you don't like black text on orange, feel free to change the colors, but don't let it get in the way of finishing the project on time.

At the start of the game, each button should display its position number (as shown above). When a player clicks on a button during a turn, the following should happen:

The game should not be active until someone presses the "Start" button. If at any time during the game, a player presses the "Start" button, the game should reset to the start of a new game. At the beginning of the game, Player X always goes first.

If, at any time, a player presses the "End" button, this should terminate the game and close the window. (This is just as if someone had pressed the "close window" button on the upper righthand corner of the window.

The "Back" button must be shown, but must remain inactive at all times. Think of it as a placeholder "for future expansion."

 

Things to Think About

  1. Take an Object-Oriented approach to designing and implementing your system.
    Use static methods ONLY if there is a compelling reason to do so.
  2. Try to make as few changes as possible to your existing code.
  3. Keep the user interaction as simple as possible.
  4. Don't add features to the game that you don't need.