你如何使MiGLayout表现得像Wrap Layout? [英] How do you make MiGLayout behave like Wrap Layout?
问题描述
我想复制此处显示的示例:
I'd like to replicate the example shown here:
使用MiGLayout。我已经尝试了一些组合,但我很难用b $ b,当容器缩小时,按钮会自动将
换行到新行。
using MiGLayout. I have tried some combinations, but I'm having a hard time making the buttons wrap automatically to new rows as the container shrinks.
有人可以提供这样做的工作示例吗?
Could someone please provide a working example doing this?
编辑:
这是程序的shell:
Here is a shell for the program:
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
public class MiGTest extends JFrame{
private JPanel jPanel;
private JButton jButton;
public static void main(String[] args) {
new MiGTest().setVisible(true);
}
public MiGTest(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new MigLayout("debug"));
initComponents();
addComponents();
pack();
}
private void addComponents() {
add(jPanel);{
for (int i = 0; i < 10; i++) {
jPanel.add(new JButton("" + i));
}
}
}
private void initComponents() {
jPanel = new JPanel(new MigLayout("debug"));
jButton = new JButton("Test");
}
}
推荐答案
根据给MiGLayout的创建者以及以下问题的答案:
According to the creators of MiGLayout and the answers to the following questions:
http://migcalendar.com/forums/viewtopic.php?f=8&t=3421
http://migcalendar.com/forums/ viewtopic.php?f = 8& t = 2270& hilit = wrap + container
http://migcalendar.com/forums/viewtopic.php?f=8&t=2015&hilit=wrap +容器
http://migcalendar.com/forums/viewtopic.php?f=8&t=1137&hilit=wrap+container
,MiGLayout完全不支持这个。它也不支持单个单元格内的
包装。
, MiGLayout quite simply doesn't support this. Neither does it support wrapping within a single cell.
这篇关于你如何使MiGLayout表现得像Wrap Layout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!