Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:56:50+00:00 2026-05-22T14:56:50+00:00

I am making Tic Tac Toe with many intermeshing classes and I encountered a

  • 0

I am making Tic Tac Toe with many intermeshing classes and I encountered a slight problem. In my version I am trying to make the board size variable, which means the buttons that represent each square cannot be referenced easily. Is there a way to identify which button is clicked if so, how? Thanks!

public class GameView extends JFrame{  
    private static final long serialVersionUID = -2869672245901003704L;
    public TicBoard game;
    private GridLayout view;

    public GameView(int height, int width)//height and width are coordinates (-y,x) across all classes
    {
        super("Tic Tac Toe");
        game = new TicBoard(height, width);
        view = new GridLayout(height,width);

        this.setLayout(view);
        for(int h = 0; h<height; h++)
            for(int w = 0;w<width;w++)
                this.add(game.getButton(h,w));

    }       
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:56:51+00:00Added an answer on May 22, 2026 at 2:56 pm

    Is there a way to identify which
    button is clicked if so, how?

    Yes.

    Add ActionListener to buttons then in actionPerformed(ActionEvent e){...} method you will have e.getSource() method to identify which has triggered this method means which button is pressed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a huge block trying to understand trees while making a Tic-Tac-Toe bot.
I have read a book and am trying to make a game of tic-tac-toe
I am trying to make a really simple Tic-Tac-Toe game. I have stored values
This is for a tic tac toe game. I need help making a check
I am making a Tic Tac Toe game and i created a function that
Ok, so I'm in the process of making a Tic-Tac-Toe game to help me
Hi I am a beginner and I am making a console tic tac toe
I am making a Tic Tac Toe Program in java because i am learning
For learning, I'm making a tic tac toe game that's intended to be played
I am making a complex tic tac toe program that has a variable grid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.