Question

Part of my application has a media component, and I'm looking for a nice volume slider I can use rather than a JSlider which looks a bit ugly for this purpose (or specifically, an extended JSlider with custom visuals would be nice). I could write one, but I don't really want to reinvent the wheel.

In terms of "nice" volume sliders - I'm looking on the lines of something like VLC:

VLC volume slider

Is there a (free) component like this already out there that I'm missing?

Was it helpful?

Solution

Jasper Potts has a nice blog post about how you can skin the slider using Nimbus Look and Feel: Skinning a slider with Nimbus.

Here is how it looks like:

enter image description here

By following the blog post, it's not very hard to make your own custom look on the slider. You may also be interested in my answer about customizing the JScrollPane using Nimbus Look and Feel with a full code example.

OTHER TIPS

Since you will want a mute operation if clicking on the speaker, I suggest that you implement your own JSlider and plug it in to the look-and-feel; however, I would also highly suggest that you reused the BoundedRangeModel that the JSlider implements.

Or, you could subclass a JPanel and package two widgets in it internally; however, this technique will require a mediator pattern to keep the two widget's displays in sync with the one shared BoundedRangeModel.

Look at the old Sun documentation about making custom widgets, and use the source code for JSlider as a starting point. It's not as hard as it may seem; however, it does take some time to get it "just right".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top