MigLayout 的文档中写道:
Full support for left-to-right and bottom-to-top layouts.
这是否意味着我可以在行中而不是从左到右添加组件,也可以在列中添加组件?所以我的意思是:
JPanel p = new JPanel(new MigLayout("flip_rows_and_columns"));
p.add(new JButton("A"));
p.add(new JButton("B"), "wrap");
p.add(new JButton("C"));
将产生:
[A][C]
[B]
而不是
[A][B]
[C]
对于某些布局来说可能会容易得多。或者可以通过某种方式实现这种行为吗?可能有什么技巧吗?
最佳答案
布局约束“flip_rows_and_columns”是“flowy”,如下所示:
MigLayout layout = new MigLayout("wrap 2, debug, flowy");
JComponent content = new JPanel(layout);
content.add(new JButton("A"));
content.add(new JButton("B"));
content.add(new JButton("C"));
也可以在细胞中使用。
关于java - 翻转 MigLayout 中的行和列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12909656/