Java - How can I create  a double JSlider? (does one exist?)

Posted on 2006-07-05
Last Modified: 2010-05-18
I need a slider that will allow the user to specify an interval. So, instead of having one marker like the Swing JSlider, it should have two: one to specify the minimum and another to specify the maximum value.

Here I have a visualization of what I'm talking about (I don't know if it exists, I photoshopped it):

 I know that with some extra code I could have two JSliders perform this function (by having one dedicated to selecting the min. value and another to the max., and not allowing them to cross) - but for stylistic reasons, I need the two markers to be on the same slide rule.

Thanks in advance for any advice on this matter!
Question by:spyderhydrant
  • 3
  • 2
LVL 35

Expert Comment

ID: 17052832
I do not think you can do it. What you can do is to define the maximum and minimum values of the JSlider.

Author Comment

ID: 17052909
Well someone's done it, I'm guessing. I'll hack the source for the JSlider class if I have to. But I don't want to reinvent the wheel if it's not necessary. I'm wondering if there is some open source extension of swing (or something else open source all together) which might provide this implementation? It just seems like something a lot of programs could make use of (such as clipping video or audio).
LVL 35

Accepted Solution

girionis earned 350 total points
ID: 17052978

Author Comment

ID: 17053048
Aha! Thank you, thank you, thank you. =)
LVL 35

Expert Comment

ID: 17053069
Thank you for accepting :) Try it and let me know if this is not what you are looking for and then we can try to hack it.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 62
javap bin 2 41
java example issue 5 26
Need help aligning JRadioButton that put in a box using GridBagLayout 2 20
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question