简体   繁体   中英

BorderLayout Swing

I m using A BorderLayout . In the north position I m having a panel called panNorth , where I'm adding some component (say for one click I'm adding one button in the next row (gridlayout)). In the main frame in the center part I will add something later.

So what is my problem now is, when ever I'm adding new controls in panNorth the size getting increased and occupy the BorderLayout's center place. So I added a JScrollPane in the north side and added the panNorth in Jscrollpane, but nothing different happened. The same thing is happening again; the size of the JScrollPane is expanding to the original size of the panNorth so it displays all the components, the scrollbar is not use full now.

So please suggest to me how to make visible only 3 rows at a time.

Try using:

jScrollPane.setPreferredSize(new Dimension(panNorth.getWidth(), desiredHeight));

This should force the JScrollPane to keep its preferred size in the North pane.

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