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".
source share