Java / Swing Volume Slider

Part of my application has a multimedia component, and I'm looking for a good volume slider that I can use, not JSlider, which looks a little ugly for this purpose (or, in particular, an extended JSlider with customizable visual effects would be nice). I could write one, but I really don't want to reinvent the wheel.

In terms of β€œgood” volume sliders, I look at lines of something like VLC:

VLC volume slider

Is there a (free) component like this already there that I am missing?

+4
source share
2 answers

Jasper Potts has a nice blog post about how you can share a slider using Nimbus Look and Feel: Hide a slider using Nimbus .

Here's what it looks like:

enter image description here

Following the blog post, it’s not very difficult to make your own appearance on the slider. You may also be interested in my answer on setting up JScrollPane using Nimbus Look and Feel with a complete code example.

+2
source

Since you want to mute the sound when you click on the speaker, I suggest you implement your own JSlider and connect it to the look; however, I also strongly recommend that you reuse the BoundedRangeModel, which implements JSlider.

Or you can subclass JPanel and pack two widgets inside it; however, this method will require an intermediary pattern to support displaying two widgets synchronously with one common BoundedRangeModel.

Take a look at the old Sun's documentation on creating custom widgets and use the source code for JSlider as a starting point. It is not as difficult as it might seem; however, it will take some time to get it "just right".

0
source

Source: https://habr.com/ru/post/1396321/


All Articles