我想複製圖示例:你如何讓MiGLayout的行爲像纏繞佈局?
使用MiGLayout。我嘗試了一些組合,但是我很難讓 在容器縮小時自動將 包裝到新行中。
有人可以提供一個工作的例子嗎?
編輯: 這裏是該程序的外殼:
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? – 2011-04-19 12:04:14
@Hovercraft引用自miglayout.com:「你永遠不必再次切換到另一個佈局管理器!」。如果事實證明MigLayout不能做到這一點,我將使用Wrap Layout代替。但我很想知道這是否可能。 – Datoraki 2011-04-19 12:22:21
我認爲MiGLayout支持這一點並將其稱爲單元格內流:有一個包含多個組件的單元,它們將像這樣流動。 – 2011-04-19 12:46:43