I'm trying to create a slider window for my program and I want be able to let it move around when dragged. The problem is that since the slider is an interactive object separate to the window itself, the only way I know of to make the slider follow the window is to use the setlocation method with the parameters of the window's x and y coordinates. What I want to happen is to not only have the slider follow the window but have the slider maintain it's current position relative to the window whilst following the window when being dragged by the mouse.
What's happening now is that since I'm using:
to move my slider alongside the window, the slider will re-affix itself to the the x-coordinate of the window no matter what position it was at previously.
Is there any sort of code/formula that will allow me to keep the slider in it's same position relative to the window while I move it around?
1 | slider.setLocation(getX(), getY() + 35 ); |