Possible Duplicate:
setMaximumSize not working in java
I've having trouble with my JFrame
subclass. I need to set a Maximum height.
But setMaximumSize
does not work. It seems that's a bug in java (setMinimumSize works). How could prevent a JFrame
from getting higher than a given height ?
In my experience, setMinimumSize and setMaximumSize are not reliable - they may work in some situations, but often not in others
The best solution is to use a ComponentListener, implement componentResized, and enforce the min / max size that way
Use this instead/as well:
setPreferredSize(new Dimension(width, height));
In my experience setPreferredSize(Dimension)
takes preference and always works.
I usually use all of them anyway: setMinimumSize()
, setMaximumSize()
, setPreferredSize()
and then setSize()
as well
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With