views:

277

answers:

1

greetngs, i am trying to learn Java and Swing by writing a simple game of connect4.

i am hoping you could guide me regarding the following issue:

to emulate the connect4 grid should i use a JTable or rely on Grid layout?

thank you.

+1  A: 

I think Grid layout would be better alt text

An example of grid layout: http://leepoint.net/notes-java/GUI/layouts/30gridlayout.html

You can use a JLabel to add the images. You can create an array of JLabels and add each one to one cell of the panel. If you need to modify the picture you just modify the Jlabel picture.

Enrique
thank you for your kind response. could you point me towards a tutorial where how to get control info from a grid cell can be retrived?
iEisenhower
what kind of control info?
Enrique
well i want to populate the grid layout with an image in each cell. and i want to be able to get the image control and change the image as needed during the game.
iEisenhower
I have added some links
Enrique
very neat idea! i like the simplicity. thank you!
iEisenhower