Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2006-07-05
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1050 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn different types of Android Layout and some basics of an Android App.
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 …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

722 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