This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Multiple sliders with a single listener - can it be done? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Multiple sliders with a single listener - can it be done?" Watch "Multiple sliders with a single listener - can it be done?" New topic
Author

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

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
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

Joined: Oct 13, 2005
Posts: 32689
    
    4
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

Joined: Sep 11, 2007
Posts: 171
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

Joined: Oct 13, 2005
Posts: 32689
    
    4
The getSource() method appears to be inherited from EventObject, so you can probably find it.

But I suspect separate Listeners is a better solution.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Multiple sliders with a single listener - can it be done?
 
Similar Threads
Your GWT wish list
Hiding images bound to sliders
ServletContextAttribute Listener doubt
Designing with exception handling
How to Read a Queue Message from MDB