| 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 ]
|
 |
 |
|
|
subject: GUI
|
|
|