我想将组件添加到MigLayout中,我可以将这些组件作为发送/接收消息添加,就像这样:
--------------------------------------------
| received message |
| sent Message|
--------------------------------------------我创建了以下构造函数:
new MigLayout(
// set the automatic wrap after columns
"insets 0, wrap 0",
// hardcode fixed column width and fixed column gap
"",
// hardcode fixed height and a zero row gap
"[]10"));当我添加一个组件时,如果我使用"push,al right“,它会为我做这项工作,但组件会占用平均高度空间,如以下链接所示:

所以我想要的就是这些组件一个接一个地在构造函数中指定gap (10)。谢谢
发布于 2020-05-12 01:51:03
尝试如下所示:
JPanel parent = JPanel( new BorderLayout() );
parent.add(yourPanelUsingMigLayout, BorderLayout.PAGE_START);
frame.add(parent);BorderLayout.PAGE_START将遵循组件的首选高度。因此,您应该看不到组件之间的垂直间距。
https://stackoverflow.com/questions/61727430
复制相似问题