Search code examples
layoutgridjtable

Swing Grid Layout or JTable


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.


Solution

  • I think Grid layout would be better alt text
    (source: stevemcc.com)

    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.