This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bidimensional array to GUI?

 
Frank Ramirez
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello eveyone
I'm working on a school project.
It is basically a maze. I have to read it from a file and create a bidimensional array with the data from the file.
I already have my bidimensional array. Now I'm trin to go a little bit extra. I want to create a GUI that displays my maze. I have a method to populate my array from the txt file. Here it is:


Is there any way that I can create some kind of GUI based in the data I get from this method? I was thinking on something like "Minesweeper" where the maze will be hidden and then the player has to go guession on all the little buttons.
Is it possible? Can anybody point me in the right direction to do this?

Thanks
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, there are many ways to represent a 2-dimensional array in a GUI. I'd consider the array to be part of the "model", which is part of the program logic and this code should not change, or only change minimally, if used with another GUI library. As a simple example, here's a small bit of code I created to help demo a similar set up (kind of like a very simplistic BattleShip game). In this code, the model that holds the 2-D array is called MyGridModel:



Feel free to ask any questions if this doesn't make sense.
 
Frank Ramirez
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer. I'm studying your code, it totally makes sense and will be a great reference to follow in my maze. Now I have another question:
I have a very little experience with GUI. I have always played in NetBeans with the Design view in JFrames and graphically added and removed buttons, field texts, etc. Is there any way to do that with this code? I mean, when I used JFrames, there is always code automatically generated that I can't change, but I can use the Design view to play with it using NetBeans. I'd like to use the design mode to add some buttons, etc.
Thanks again, you have been very helpful
 
pete stein
Bartender
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank Ramirez wrote:Thank you for your answer. I'm studying your code, it totally makes sense and will be a great reference to follow in my maze. Now I have another question:
I have a very little experience with GUI. I have always played in NetBeans with the Design view in JFrames and graphically added and removed buttons, field texts, etc. Is there any way to do that with this code? I mean, when I used JFrames, there is always code automatically generated that I can't change, but I can use the Design view to play with it using NetBeans. I'd like to use the design mode to add some buttons, etc.
Thanks again, you have been very helpful


My advice is to toss out the design view and learn to code Swing by hand using the Sun Swing tutorials as a guide. Then later you can apply this understanding to NetBeans generated code, sure, but first learn the basics. Much luck!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic