How to set maximum JPanel width but to stay height free to grow?
How to set maximum JPanel width but to stay height free to grow ? ( I can开发者_开发问答not use prefferedSize for strange reason ).
Use LayoutManagers. BoxLayout
, GridBagLayout
, or some other layout will allow you to define a single direction of growth for a panel.
One possibility is use MigLayout http://www.miglayout.com/
There you can easily override minimal:prefered:maximal size. And mainly it works properly.
精彩评论