Being Nice to your Layout manager - Is this the right way?

Ive written a custom component that basically provides multi-line text wrapping and a few other nice things.

I had a bit of trouble when I came to implementing

getPreferredSize() getMinimumSize()

This is because ideally, I'd like the component to use as much space horizontally as possible, whilst using only as much vertical space as necessary.

To do this, I used the parents width as the minimum horizontal size. This then allowed me to work out the height.

Question is - is that the right way to do it? Other than that, I just cant think of a way to get the width I need when the component is first added to its container.

Cheers for any input,

Dave

[718 byte] By [ irvingdi] at [2007-9-26 17:29:41]
# 1

If you want it to use as much horizontal space as possible, that means you want its width to be equal to its container's width (perhaps minus a bit for borders or something). So in that case you would have to set its minimum width to that number, and that's exactly what you did. There could be other ways to do it, but yours seems perfectly fine to me.

DrClap at 2007-7-2 22:37:04 > top of Java-index,Archived Forums,Swing...
# 2
Thanks - much appreciated.
irvingdi at 2007-7-2 22:37:04 > top of Java-index,Archived Forums,Swing...