Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make JButtons working together?

 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
How is possible to make JButtons who have same ImageIcon and are consecutive to change for example image when you click one of them?
Consecutive i mean(1s are JButtons with same image):

0000000
0010000
0010010
0000010
1000010
0000000

or

0000000
0000000
1111000
0000000
0001100
0000000
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know where you're stuck (since you didn't tell us!) all I can so is suggest some tutorials.
http://download.oracle.com/javase/tutorial/uiswing/components/button.html
http://download.oracle.com/javase/tutorial/uiswing/events/actionlistener.html
http://download.oracle.com/javase/tutorial/uiswing/components/icon.html
 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didnt start coding yet, im just thinking it. I have stuck at the point how to make those JButtons "group"
 
Jan Hoppmann
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you want to do here seems like a finite state machine to me, so: yup, it's possible.
If you want to change the buttons which have the images randomly it's a bit less complicated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic