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 6997023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:13:52+00:00 2026-05-27T20:13:52+00:00

I am creating a game where each player fills a 3×3 grid and they

  • 0

I am creating a game where each player fills a 3×3 grid and they all have a different state of the grid (a player object has an instance variable as the grid and the grid is made up of many JPanels).

I have a JList of players on the left and on the right the grid is displayed. Is there a way to dynamically change the grid when I click on a player’s name in the list?

(I tried doing a for loop to update the grid every time a player is selected but then if the player updates the grid after he is selected, it gets hacky to update the grid i.e you have to make the list get the focus etc. so I am looking for a clean way)

EDIT: Also, I thought about changing the reference of the object dynamically and update the UI however I have some action events which enforces me to make the variables FINAL. So I am unable to do this way either.

  • 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-27T20:13:53+00:00Added an answer on May 27, 2026 at 8:13 pm

    You should not change the grid when the selection changes. You should change the data displayed by the grid (i.e. the data model of the grid). For example, suppose the grid is a panel containing 9 labels, each displaying one element of a String[][]. Your Grid object should have a setModel(String[][] data) which changes the value of each label in the grid.

    Each time the player selection changes, you should ask the selected player for its data, and call setData() on the grid. If the data of a player can change while being delected, you should also call setData() each time it changes. This can be done by having a PropertyChangeEvent triggered by the Player when its data changes, and a listener which updates the grid with the new data if the player triggering the event is the selected player.

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

Sidebar

Related Questions

I am creating an object orientated mastermind game. I have all the classes and
I am creating a card game in Silverlight. Each player has a Hand which
I'm creating a building game in JavaScript and PHP that involves a grid. Each
I am creating a database that tracks replays for a game. Each replay has
I have a player, game, shot, round and team model. When creating a shot,
Basically, I am creating a pseudo-RPG game where a player has an inventory of
I'm creating an online game in PHP where users can create playable characters. Each
im creating a game that has multiple levels and the levels contain multiple textures
Hello I'm creating a game and I have a few ways to make trainers
I have started creating a game, and I added a second project, it's the

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.