在 Swing 中,布局具有不同高度的组件
我们有不同高度的组件,我们希望以垂直方向上尽可能少的空间的方式显示它们(如图所示),我们如何使用 miglayout 来做到这一点?
We have components that have different heights, we want to show them in a way that vertically there is as little space as possible (as shown in the picture), how can we do that using miglayout?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经使用过 MigLayout 相当多了,我不确定是否有一个真正好的方法来做到这一点。你真正想要的是有 5 列并在 y 轴上使用 split ,不幸的是你不能这样做。
我看到三种方法:
1)使用 5 个 jpanels,每列一个,并在 MigLayout 中为每列使用 flowy
2)设置一个矩阵并将每个组件分配给多个单元格
等。如果您不这样做,这会很有效每列“跨度”中有很多不同的端点,
这里可能会更干净一些:
3)使用“nogrid”并仅在每个组件上设置大小边界
I've used MigLayout quite a bit, I'm not sure there's a really nice way to do this. What you really want is to have 5 columns and use split on the y axis which you can't do unfortunately.
I see three approaches:
1) Use 5 jpanels, one for each column and just use flowy in MigLayout for each column
2) Setup a matrix and assign each component to a number of cells
etc.. This works if pretty well if you don't have a lot of different end points in each column
"span" might be a little cleaner here:
3) Use "nogrid" and just set size bounds on each component