Java MiGLayout问题

时间:2015-05-07 17:40:23

标签: java layout resize miglayout

所以目前我正在尝试编写一个简单的聊天程序并使用MiG布局进行调整大小。

这就是我目前所拥有的: enter image description here

当我展开它时,一段时间后元素停止对齐,如下所示: enter image description here

代码:

int GridAmount = 30;
    int fh = (Client.JF.getHeight()/GridAmount);
    int fw = (Client.JF.getWidth()/GridAmount); 
    String ffh = "";
    String ffw = "";        
    for(int x = 0;x != GridAmount+1;x++){
        ffh = ffh + "[" + fh + "px]";
        ffw = ffw + "[" + fw + "px]";
    }
    setLayout(new MigLayout("debug", ffw, ffh));

    JTextPane textPane = new JTextPane();
    add(textPane, "cell 0 0 28 29,grow");

    String[] selections = { "exampleuser1", "exampleuser2", "orange", "yellow" };

    JLabel lblNewLabel = new JLabel("Users Currently Online");
    add(lblNewLabel, "cell 28 0,aligny center");

    JList list = new JList(selections);
    add(list, "cell 29 1 8 8,grow, align right");

    JTextField textField_3;
    textField_3 = new JTextField();
    add(textField_3, "cell 0 29 39 0,growx");
    textField_3.setColumns(10);

    JButton btnPost = new JButton();
    add(btnPost, "cell 29 9, grow");

0 个答案:

没有答案