The moose likes Beginning Java and the fly likes How to make JButtons working together? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to make JButtons working together?" Watch "How to make JButtons working together?" New topic
Author

How to make JButtons working together?

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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

Joined: May 03, 2008
Posts: 4167
    
    3

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


luck, db
There are no new questions, but there may be new answers.
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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

Joined: Jul 19, 2010
Posts: 99

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.


Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to make JButtons working together?
 
Similar Threads
New Year Resolutions...
Limit of Byte
JButtons not buttons?
JButton -> Size
JButtons border to be the same color as the JPanel