简体   繁体   中英

MigLayout 50% width

I have a Panel which is a contentPane of a JDialog . That Panel is divided horizontally into two parts. UpperHalfPanel and LowerHalfPanel by:

Panel.add("UpperHalfPanel", "wrap");
Panel.add("LowerHalfPanel");

The LowerHalfPanel is divided vertically into two parts. LowerHalfLeftPanel and LowerHalfRightPanel .

Now the size of the UpperHalfPanel is determined by number of columns of a JTextField and I am finding a way to make the LowerHalfLeftPanel and LowerHalfRightPanel fill 50% of width of LowerHalfPanel .

Briefly it can be described as a Table with two row and the bottom row has two equal column.

Maybe you are looking for split/span. Without more of a code example, it's hard to say. A lot of times I find that MigLayout makes nested panels unnecessary. If you come up with a simple short example or even a mock image, it would help.

It sounds like you want this:

JPanel outerPanel = new JPanel(new MigLayout());
JPanel upperPanel = new JPanel();
JPanel lowerLeftPanel = new JPanel();
JPanel lowerRightPanel = new JPanel();

outerPanel.add(upperPanel, "span 2, wrap");
outerPanel.add(lowerLeftPanel);
outerPanel.add(lowerRightPanel);

This will make upper panel span 2 "cells" and the lower left and right be evenly divided under it depending on the contents of those panels. There are ways to force the size, such as the "!" or "wmin". Try out the swing demo , go to the span section. Right clicking on the areas will let you experiment with the contraints. Also see the MigLayout cheat sheet .

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