Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Colourful arrays!!

 
Mike Smike
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone,

I've created a game which consists of a Game class and an Interface class. The interface is simply a 10 x 10 grid of squares, each holding a value. In the Game class, there is an int array of [100] which stores all the values. In the Interface class, there is a JTextField array of [100] which prints out the values in the Game class array.

My problem is this. There are two players playing the game. Each has a different colour. I want each player's square to have the background colour of that player. How can I do this?

I know how to set the background colour of a text box, but how can I specify only to do this when a square belongs to Player 1 or Player 2? Is there a way to build the Game class array, with int values, and have each value associated with a Player? So two objects per item in the array? That way I suppose I could set the colour using comparsion operators. Is there an easier way?

Thanks loads for any help you can give me! I need to have this done by tomorrow

Thanks guys

Mike
 
Mike Smike
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm well I seemed to have solved the probelm. I just created an object which held both a value and a player object and created an array of them. Not extremely elegant but probably not a bad solution.

Thanks

Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic