I have just realised that JSlider cannot deal with floating point numbers. Can anybody recommend a Swing/AWT alternative that can?
EDIT: Or a workaround of some description.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sliders in general deal with ranges of numbers. From a practical implementation, each slider must have two elements:
It is the “finite number” that is causing you the trouble. Without a finite number of increments, the slider cannot fit on a screen. With a finite number of increments, it is impossible to select a
floatnumber that lies between two incremental “steps”.In short, it is impossible; so, here’s the workaround:
0.0fto10.0for whatever, it doesn’t matter, but you must have a range.0.1for0.001for whatever, it doesn’t matter, but you must have an increment.An example, for
5.0fto10.0fwith0.1fincrements: