I have a JList with a VERTICAL_WRAP layout orientation. The list is in a JScrollPane. Everything is fine if I use the scrollbar buttons/arrows or click on the scrollbar's track. The scrolling is "savvy" i.e., it scrolls a row at a time. The weirdness occurs when I drag the scrollbar's knob. The knob may be left in a position that doesn't correspond to the value returned by the scrollbar's getValue() method. For example, getValue() might return 0, but the knob is not all the way to the left. I would like the knob to snap to the nearest tick, so to speak/write. How can I do this?
I'm using the windows look and feel. When using the java laf I don't notice the problem, but the scrolling isn't savvy.
Thanks for the response. Your code works perfectly when I use the default look and feel. However, when I use the windows look and feel I'm not getting the snap behavior. For some reason the number returned by getValue() doesn't correspond to the position of the knob.