Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI

 
Smitha Prasad
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear smitha
try this code:code:

[ April 10, 2002: Message edited by: Cindy Glass ]
 
Smitha Prasad
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm not sure I'm understanding your question exactly. Would you elaborate a bit?
 
Sayed Ibrahim Hashimi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ali Ashraf
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic