Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24858
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2013-07-31 10:34 -0700 |
| References | <81940cb0-8687-40f5-8eda-68bf8c8ff935@googlegroups.com> <nospam-52F747.21570130072013@news.aioe.org> |
| Message-ID | <cb89e71e-9972-43e9-8ed0-53be5f18833b@googlegroups.com> (permalink) |
| Subject | Re: JSlider interactions |
| From | FredK <fred.l.kleinschmidt@gmail.com> |
On Tuesday, July 30, 2013 6:57:01 PM UTC-7, John B. Matthews wrote:
> In article <81940cb0-8687-40f5-8eda-68bf8c8ff935@googlegroups.com>,
>
> FredK <fred.l.kleinschmidt@gmail.com> wrote:
>
>
>
> > Is there a way to set the block increment for a JSlider ? By this I
>
> > mean the change in value that occurs when the user clicks between the
>
> > current position and one of the ends (similar to the block or unit
>
> > increment for a JScrollBar). I can't find anything to do this in
>
> > JScrollBar or BoundedRangeModel.
>
> >
>
> > Or is it a UI-specific amount (I am using Nimbus).
>
> >
>
> > For an integer slider, I want to drag the knob to the approximate
>
> > position, and then be able to click near it to move one integer at a
>
> > time. It appears that the default amount is 10% of the range, so when
>
> > the range is from 0 to 40, clicking in the "trough" area moves the
>
> > value by 4.
>
>
>
> This handled by an instance of BasicSliderUI.TrackListener, for which
>
> you'll need a custom UI delegate, as shown here,
>
>
>
> <http://stackoverflow.com/a/518672/230513>
>
>
>
> and in How to Write a Custom Swing Component:
>
>
>
> <https://today.java.net/pub/a/today/2007/02/22/how-to-write-custom-swing-component.html>
>
>
>
> Interestingly, BasicSliderUI.ScrollListener is public, apparently to
>
> work around an IE bug.
>
>
>
> As an aside, the API for each says.
>
>
>
> Instantiate it only within subclasses of .
>
>
>
> while the source says,
>
>
>
> Instantiate it only within subclasses of <Foo>.
>
>
I tried:
slider.setUI( new BasicSliderUI( slider ) {
@Override
protected void scrollDueToClickInTrack( int direction ) {
int value = slider.getValue();
value += direction;
slider.setValue( value );
}
} );
which works, but gives me a Basic LAF. The rest of my app is using Nimbus.
I haven't been able to figure out how to find or use a Nimbus SliderUI.
When I call slider.getUI(), it returns an instance of javax.swing.plaf.synth.SynthSliderUI.
If I change BasicSliderUI in the above code with SynthSliderUI, I get
an error saying that that class is not visible.
(Using Java 1.6)
--
Fred K
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
JSlider interactions FredK <fred.l.kleinschmidt@gmail.com> - 2013-07-30 14:24 -0700
Re: JSlider interactions "John B. Matthews" <nospam@nospam.invalid> - 2013-07-30 21:57 -0400
Re: JSlider interactions FredK <fred.l.kleinschmidt@gmail.com> - 2013-07-31 10:34 -0700
Re: JSlider interactions "John B. Matthews" <nospam@nospam.invalid> - 2013-08-01 17:50 -0400
csiph-web