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

Calculating width of JList vertical scrollbar  RSS feed

 
Diana McHenry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've got a requirement stating that I should only display tooltips for my combo box values when the item text is longer than the width of the combo box. This seems reasonable, but JList.getWidth() appears to include the scrollbar width. As such, if I hover over a combo box value that goes beyond the left side of the scrollbar, but not beyond the right side of the scrollbar, no tool tips

Does anyone know how I can accurately calculate the width of the scrollbar alone? I've been digging through Swing's APIs, but have not had much luck.

Thanks for any help you can provide!

Diana
 
Diana McHenry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha! Here's the answer:

int scrollBarSize = ((Integer)UIManager.get("ScrollBar.width")).intValue();

Whew!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!