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
3 replies to this topic
#1
Posted 22 May 2011 - 10:35 AM
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz|
|
|
#2
Posted 26 May 2011 - 06:52 AM
?!?! I don't really get what you mean..
#3
Posted 23 February 2012 - 03:52 PM
Is that Binary ......... (~_^) :confused:
#4
Posted 23 February 2012 - 04:18 PM
You could subclass JButton with MyJButton and give it a special attribute like :
On creation of each MyJButton object, set the name of the icon. Example: icon1.gif
Then when a button is clicked, you'll have to decide whether or not consecutive buttons have the same icon name.
Example:
If you want to save some time (and NOT extend JButton), you can use JButton's setName(...) and getName() methods.
String iconName ...
On creation of each MyJButton object, set the name of the icon. Example: icon1.gif
Then when a button is clicked, you'll have to decide whether or not consecutive buttons have the same icon name.
Example:
//when a button is clicked this.changeIcon(...); for( each neighbor of clicked_button ) if( neighbor.iconName = this.iconName ) neighbor.changeIcon(...)
If you want to save some time (and NOT extend JButton), you can use JButton's setName(...) and getName() methods.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









