简体   繁体   中英

How to make a board in Java using 2D arrays and JTable ?

What I have in mind is to make a JTable. The model will use the 2D array's columncount and rowcount to set the JTable's rows and columns.

What I cant figure out is how do I go around making fields for these cells in the table?

Example fields like - Status(boolean), Image etc. So by having these fields I want to edit the cells when the application is running and show the user the updates.

I have tried to make a 2D object and add fields in there. But it doesnt seem to work.

What would be a good way to build this?

I am using swing to build this.

This isn't a very specific question so that limits the answer I can give - from what you want to do, I'd suggest

  1. Making sure you understand how the Model-View-Controller paradigm works in Swing
  2. Looking into the Observer / Observable framework and how it fits in with MVC
  3. Extending some sort of Swing Component to reflect changes in your model.

Once you've covered the above you should find that implementing what you want to do is reasonably trivial, and that you can ask more directed questions that will get better responses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM