MigLayout 50% 宽度
我有一个面板,它是 JDialog
的 contentPane。该面板水平分为两部分。 UpperHalfPanel
和 LowerHalfPanel
通过:
Panel.add("UpperHalfPanel", "wrap");
Panel.add("LowerHalfPanel");
LowerHalfPanel
垂直分为两部分。 LowerHalfLeftPanel
和 LowerHalfRightPanel
。
现在 UpperHalfPanel
的大小由 JTextField
的列数决定,我正在寻找一种方法来制作 LowerHalfLeftPanel
和 LowerHalfRightPanel
填充 LowerHalfPanel
宽度的 50%。
简而言之,它可以被描述为一个有两行的表格,底行有两个相等的列。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您正在寻找分割/跨度。如果没有更多代码示例,很难说。很多时候我发现 MigLayout 使得嵌套面板变得不必要。如果您想出一个简单的简短示例,甚至是模拟图像,都会有所帮助。
听起来你想要这样:
这将使上部面板跨越 2 个“单元格”,并且根据这些面板的内容,左下角和右下角在其下方均匀划分。有一些方法可以强制大小,例如“!”或“wmin”。尝试 swing 演示,转到跨度部分。右键单击这些区域将让您尝试这些限制。另请参阅 MigLayout 备忘单。
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:
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.