Question

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.

Was it helpful?

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.

OTHER TIPS

Yes you can do this. Simply get the value from the JSlider that's being dragged and use it to set the BoundedRangeModel of the other JSlider.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top