File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JSlider with default point Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JSlider with default point" Watch "JSlider with default point" New topic

JSlider with default point

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 246

I have a doubt about JSlider . in my case i want a the pointer should points to middle( present value) user can drag to right or left if user drag it to left the value should minus the points he dragged and with right drag opsit to that action. is it possible
when user drag and leave the pointer it should come back to default position.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

What exactly are you stuck on?

Do you know how to construct and display a JSlider in your GUI?
Do you know how to make a slider that is initially set to the middle of its range?
Do you know how to query the value of a slider?
Do you know how to set the value of a slider in code?
Do you know how to listen for changes in a slider's value?

The answers to these can be found in the tutorial linked from the API for JSlider. Give it your best shot and see if you run into any problems. You shouldn't, but if you do, post your attempt in the form of an SSCCE <-- link and ask a specific question.

luck, db
There are no new questions, but there may be new answers.
It is sorta covered in the JavaRanch Style Guide.
subject: JSlider with default point
It's not a secret anymore!