aspose file tools*
The moose likes Game Development and the fly likes access the sources of the JButtons with no labels but Icons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "access the sources of the JButtons with no labels but Icons" Watch "access the sources of the JButtons with no labels but Icons" New topic
Author

access the sources of the JButtons with no labels but Icons

Philip Joshua Gaje
Greenhorn

Joined: Mar 19, 2012
Posts: 2
java.lang.Sample [size=12]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
How would you do it if the buttons had
labels (text?) and no icons?

or both?
Philip Joshua Gaje
Greenhorn

Joined: Mar 19, 2012
Posts: 2
if the button had a label, I often use event.getSource() to access that button. I just don't know what to use if both label and icon are not in the button, and specifically i only used a button with icon but without label.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
what does event.getSource() return?
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

the link is not working. e.getSource() returns the name of the member variable that caused the event(i'm pretty sure). i like it better with text on my button. i can then say e.getSource().getText(). or better yet i can use e.getActionComand()


SCJP
Visit my download page
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> e.getSource() returns the name of the member variable that caused the event

the question was directed at the OP, to get him to think about what he's doing
i.e. if he can access the button when it has text, why can't he access it with no text
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

e.getSource().getText() is not the same as e.getActionComand(). Former gets the text of the button and later gets the string used for the command. Both are not necessarily the same.


Please correct my English.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access the sources of the JButtons with no labels but Icons