Swing GridBagLayout放置

时间:2013-12-12 19:32:17

标签: java swing layout gridbaglayout

我将组件放在我想要的位置时遇到问题。

我希望我的explain_lbl位于左上角,然后在它下面我想要NORM_lbl,在NORM_lbl的左边我想要NORM_bar。在他们之下,我想要PTR_lbl ......等等。我该怎么做?

GridBagConstraints gc = new GridBagConstraints();
        gc.anchor = GridBagConstraints.NORTHWEST;

        pane.add(explain_lbl, gc);
        gc.gridx = 0;
        gc.gridy = 0;

        pane.add(NORM_lbl, gc);
        gc.gridx = 1;
        gc.gridy = 1;

        pane.add(NORM_bar, gc);
        gc.gridx = 1;
        gc.gridy = 2; 

        pane.add(PTR_lbl, gc);
        gc.gridx = 0;
        gc.gridy = 1;

        pane.add(PTR_bar, gc);
        gc.gridx = 1;
        gc.gridy = 1;

        pane.add(btn_play, gc); 
        gc.gridx = 3; 
        gc.gridy = 3;

0 个答案:

没有答案