Search code examples
javaswingjslider

Is it Possible to Click two JSliders At once


I am trying to select a coordinate from a grid using JSliders. Can I make it so when it clicks one it clicks the other as well, one is vertical while the other is horizontal? So I can drag them both at once.

What I'm trying to do is set the horizontal slider based on horizontal movements of the mouse and set the vertical slider based on vertical movements of the mouse.


Solution

  • What I'm trying to do is set the horizontal slider based on horizontal movements of the mouse and set the vertical slider based on vertical movements of the mouse.

    Instead I would attach a mouse listener to the area itself, and match the x/y sliders to match the mouse co-ordinates. Of course, it would help to have the sliders also change the position, but independently of each other.