Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JList JScrollPane problem  RSS feed

 
Mike Rane
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Mike Rane
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Craig,

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.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Mike Rane
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect

Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!