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.
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.)
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.
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss