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

how to add JButtons to an array

 
mike ryan
Ranch Hand
Posts: 210
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have a GUI i have created a gui qith 16 JButtons

example of how i created them



they go from A1-A4 to D1-D4 ,four rows.
I would like to add the JButtons to an array, how should i go about it? i am guessing it is possible but maybe i am wrong?

i would like to make something like JButton[] rowA = JButton{A1,A2,A3,A4}; -----> i am really terrible whith Arrays!!

Thanks
Mike
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suggest you get yourself a factory method.You would have to check the syntax, and that I have got the names of all the methods right. You can overload that method to your heart’s content. You can use Actions instead of Listeners.
 
mike ryan
Ranch Hand
Posts: 210
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Campbell,

Thanks for your response, that would be a good way to create the buttons, but i have already created them and want to have them in a list of rows.Maybe you missunderstood my question OR i don't understand your reply <--- (which is possible ;) ).

I am currently trying this with ArrayList



i will eventually need to test quite a few things in each row like if rowA doesn't equal an even number it will be false as well as if there are more than three of the same numbers beside eachother it will be false and so on,
i am thinking this will get really long with all the checks, maybe there is a better solution?

Thanks
Mike
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic