简体   繁体   中英

Stacking JPanels in the same direction

I would like to stack JPanels on in the same direction. I've searched this and can't find anything. The results that show up mean "overlap".

This is what I mean:

在此处输入图片说明

I would like to stack the second JPanel underneath the first. When using: add(BorderLayout.NORTH) on both layouts it overlaps them.

I appreciate any help, thanks!

How I usually code something specific like this, I like to use the GridLayout , and set it to 2 Rows and 1 Column like so.

  //this will go with the boiler plate
 this.setlayout(new GridLayout(2,1));

This should fix the problem of the two JPanels, and you can always add more to the rows if needed.

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