File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "GUI" Watch "GUI" New topic
Author

GUI

Smitha Prasad
Ranch Hand

Joined: Apr 02, 2002
Posts: 41
i want to make a button a listener to the action from a source which is another button. for example if i have two buttons, yellow button and blue button and i want to make the blue button a listener to the yellow button... if the yellow button is clicked the label of the blue button should change.
Ali Ashraf
Greenhorn

Joined: Mar 30, 2002
Posts: 5
Dear smitha
try this code:code:

[ April 10, 2002: Message edited by: Cindy Glass ]

[Smart Rancher]
Smitha Prasad
Ranch Hand

Joined: Apr 02, 2002
Posts: 41
thanks Ashraf, the reference to the listener is through "this". is there any other mechanism of giving reference to the blue button , i.e making the button a listener directly.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Well, I'm not sure I'm understanding your question exactly. Would you elaborate a bit?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
I'm not sure I know exactly what you are talking about either.
Why would you want your button handle the events? Its a button not an event handler.
If you are using Swing you might want to look into the Action class.
[ April 10, 2002: Message edited by: Ibrahim Hashimi ]
[ April 10, 2002: Message edited by: Ibrahim Hashimi ]

SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
Ali Ashraf
Greenhorn

Joined: Mar 30, 2002
Posts: 5
No the button cannot act as an event handler.
button is a component, it generates an event and a listener handel this event.
please look at Events and Listeners.
[ April 10, 2002: Message edited by: Muhammad Ali Ashraf ]
 
jQuery in Action, 2nd edition
 
subject: GUI
 
Similar Threads
Tough interview question. Inputs welcome
Finding number of options selected in multiple choice button
modifying enums
IPL
problem with updating Panel!