简体   繁体   中英

How do I programatically resize a component in a BorderLayout?

I have a JPanel that is located at the BorderLayout.SOUTH position of a parent JPanel. I would like to programatically change the height of this child JPanel.

I am calling childPanel.setPreferredSize(new Dimension(getWidth(), newHeight)); , but it has no effect. (I have tried setting the Maximum and Minimum sizes as well.)

What (probably very simple thing) am I missing?

After changing the preferred size, you need to call revalidate() on that childPanel.

You may want to read this Oracle Tutorial on LayoutManagers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM