Results 1 to 8 of 8
- 07-12-2011, 02:15 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
Changing Image Icon of a JButton at run time, NOT state dependent
Hi all,
I need to change the Image Icon of a JButton. I know there are built in methods to change the Icon when it is in a certain state (i.e. pressed, scrolled over, etc). But I need it to change when another method tells it to.
Basically an action happens, a method decides what to change the JButton's Image Icon to (depending on what happens in the action), then it changes it. That's what I want in theory, anyways.
Are there any simple solutions to this?
Thanks
- 07-12-2011, 02:38 PM #2
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-12-2011, 02:39 PM #3
Have you read the API doc for the JButton class? Do any of the methods look like they would do what you want them to do? Have you written a small program to test those methods to see if the work like you want?
If you are having problems with your small test program code, post it here with your questions.
- 07-12-2011, 02:48 PM #4
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
secticon()
Sets the button's default icon. This icon is also used as the "pressed" and "disabled" icon if there is no explicitly set pressed icon.
Parameters:
defaultIcon - the icon used as the default image
See Also:
getIcon(), setPressedIcon(javax.swing.Icon)
--------------------------------------------------------------------------------
I don't want to set a default image. If anything that's the opposite of what I need to do.
- 07-12-2011, 02:51 PM #5
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-12-2011, 02:52 PM #6
Have you tried it to see what happens?
The class has methods you can use to work with its icons. If what you want to do is not there, then it's not there.
- 07-12-2011, 03:52 PM #7
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
- 07-12-2011, 04:19 PM #8
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Similar Threads
-
changing JButton image upon clicking
By Logical in forum AWT / SwingReplies: 2Last Post: 12-21-2010, 02:53 AM -
Changing Java Icon
By Adam Cruge in forum Java 2DReplies: 20Last Post: 07-21-2009, 02:32 AM -
Changing colors of an image in real time
By chale in forum CLDC and MIDPReplies: 0Last Post: 05-06-2009, 03:04 PM -
Time constraints on object state
By Flipke in forum New To JavaReplies: 4Last Post: 04-11-2009, 06:12 PM -
Changing icon of JOptionPane
By mew in forum New To JavaReplies: 3Last Post: 12-21-2007, 07:01 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks