2

Can someone show me code that will set up a JSlider except, instead of a thumb, it is a circle? Specifically, instead of that little triangle which points to the current position, it is a blue circle of width 100;

CodeGuy
  • 28,427
  • 76
  • 200
  • 317
  • same question as often: why? Standard - in both look and feel - components are standardized for a reason ... – kleopatra Aug 18 '11 at 07:48
  • because I'm customizing the slider. while it's java code, the look and feel of a final java application does not necessarily have to always be java-looking. – CodeGuy Aug 18 '11 at 20:38
  • agreed, not necessarily java-whatever-that-means - but it has to look consistent and be functional and usable. Getting both right is not trivial, big companies pay big money for user studies. Thinking you or me could get similar results is .. a bit over-optimistic ;-) – kleopatra Aug 18 '11 at 22:41

1 Answers1

1

Assuming you're using the Metal L&F you could extend javax.swing.plaf.metal.MetalSliderUI and override the horizThumbIcon or vertThumbIcon to be your circle. Then set this UI to be UI you'd like for your sider using slider.setUI()

look at this the answer here which performs a change for a JComboBox How can I change the arrow style in a JComboBox.

Community
  • 1
  • 1
Varun Madiath
  • 3,152
  • 4
  • 30
  • 46
  • +1 Changing the `Icon` in `MetalSliderUI` seems convenient. See also these [examples](http://stackoverflow.com/questions/6992633/painting-the-slider-icon-of-jslider/6996263). – trashgod Aug 17 '11 at 15:32
  • -1 for setting a ui delegate on a single component instance. That will not survive any updateUI nor be safely consistent across any the application. – kleopatra Aug 18 '11 at 22:44