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

Specific size requirements with scrollbar  RSS feed

 
John Blanco
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a component that needs to maintain a certain height, even when the horizontal scrollbar of the JScrollPane that wraps it appears.

So, it needs to be 32 pixels high, PLUS whatever height of the horizontal scrollbar. Can I take this into account in my getPreferredSize() return? IO tried (32 + getInsets().height), but the insets come back as 0 and are unaffected by the scrollbar.

Any ideas?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a Swing question to me, but at any rate my idea would be to always show the horizontal scrollbar. Not only would this solve your problem, it would also prevent your component from suddenly resizing itself and possibly causing the entire layout to resize itself. (I am not a fan of "twitchy" Swing designs where component sizes change all the time.)
 
John Blanco
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it is Swing...sorry, didn't notice the specific forum. :-) Just writing back to say that I found my answer. It's not coding, it's framework. I used the Scrollable interface to specify the required dimensions in my custom component.

I wasn't familiar with this interface, and I'm a little dissapointed that "Java Swing" doesn't cover it. But, they did mention it...and the rest was a piece of cake.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!