0

I trying to create a JSlider object which has its line looking like an arc, there are minimum number of tick marks (though some may not have a value) and the slider indicator is a simple line drawn from the centre of the arc to the currently selected tick mark. It looks like I may have to extend the BasicSliderUI and override the various paint methods. Is there an example of something like this already or do I have create this object from scratch?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Tony
  • 414
  • 4
  • 7
  • 1
    Making a straight line drag across or up/down a GUI using a mouse is a natural movement. But 'radial movement' is a lot less natural, and harder to do. For the sake of your users, please drop this idea. – Andrew Thompson Apr 18 '12 at 05:22
  • You might also look at [tag:jfreechart] dial plots, mentioned [here](http://stackoverflow.com/q/6799536/230513). – trashgod Apr 18 '12 at 05:36
  • Unfortunately I have to mimic an existing user interface and for some reason the original designer chose these dials. I agree it is a bad UI but that is what I am stuck with. Although since this is a touch screen interface the line may not be as big a problem as you think. – Tony Apr 23 '12 at 05:58

1 Answers1

2

This example illustrates how to override the paintTrack() method of BasicSliderUI. It looks like you could draw an Arc2D to get the effect you want.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • More on rendering `Arc2D` may be found [here](http://stackoverflow.com/a/7343420/230513). – trashgod Apr 18 '12 at 06:38
  • The only problem with using a slider is that it looks like the labels are always drawn below the track. I actually need to draw them above the line. For the amount of overrideing it may be easier to just have my own component. It just that I need the behaviour of setSnapToTicks(true). That why I wanted to start from the slider. I had already found the gradient paint example and that is what I have been using in my prototype. – Tony Apr 23 '12 at 05:59