-1

It is very common that we use JSliders in our java applications. But I want to replace JSliders by knobs. I need some guidance to study in this respect.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Harjit Singh
  • 905
  • 1
  • 8
  • 17
  • You need to ask a more precise question. – kviiri May 17 '14 at 18:12
  • @kviiri I am using JSlider adding change listner to it for catching change events in java stand alone application. I want to replace JSlider by knob. How it can be done? – Harjit Singh May 17 '14 at 18:31

1 Answers1

0

Preable: Not sure how good knobs are for the usability of the UI. I would avoid them if not for touch screen interfaces.

The is no Java support for components like Knobs so you have to create your own. Here you can find a basic example with a really simple graphic but that consist in proof of concept.

If you want to edit that code some suggestions that I give you are:

  • Change the paint method for the paintComponent. If you don't know why here the explanation.

  • Use the antialiasing adding the following line of code at the beginning of the paintComponent method. The picture shows you the difference.

Normal vs Antialiasing

   Graphics2D g2 = (Graphics2D)g;
   g2.setRenderingHints(
     new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
   );
Community
  • 1
  • 1
Nicola
  • 395
  • 2
  • 13