This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple sliders with a single listener - can it be done?

 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I have more than one JSlider reporting to a single ChangeListener, and be able to tell which one is triggering the event? If so, how? I currently have three sliders on my window and they are reporting to the same listener, but I can't seem to find out how to tell which one is being moved.
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try the getSource() method if your Event has such a method.

But it sounds like a peculiar design to me.
 
Mike Lipay
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I knew you could identify buttons, wasn't sure if sliders worked the same, apparently not. I'll just create multiple listeners.
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getSource() method appears to be inherited from EventObject, so you can probably find it.

But I suspect separate Listeners is a better solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic