2

Is it possible to display two set of labels with the same ticks on JSlider, one on top, one on bottom?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user121196
  • 30,032
  • 57
  • 148
  • 198
  • I can't see there any JLabel, maybe JTextField or JFormattedTextField – mKorbel May 03 '12 at 19:26
  • 1
    Why would you want this in the first place ? Each tick only represents one value, so why would you need to labels ? Will this not simply confuse a user. I do not remember seeing sliders with two different labels for the same tick – Robin May 03 '12 at 21:32

1 Answers1

1

You can implement your own SliderUI, as shown here, and override paintTicks().

image

Alternatively, you may be trying to represent alternate units, such as Celsius v. Kelvin. You might want to consider one of these options:

  • Add an adjacent toggle button to switch the displayed tick units.

  • Add a second JSlider and let each one's ChangeListener set the other's model to the equivalent setting.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045