我試圖移動我的按鈕和標籤。我希望按鈕位於右下角,而標籤正好位於它們的上方,但無論如何更改佈局系統,它們都卡在同一行,並且根本不會移動。如何讓他們移動?GridBagLayout元素不移動
setLayout(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();
gc.anchor = GridBagConstraints.CENTER;
gc.weighty = 1;
gc.gridx = 0;
gc.gridy = 0;
gc.ipadx = 5;
pane.add(explain_lbl, gc);
gc.ipadx = 1;
gc.gridy = 1;
gc.anchor = GridBagConstraints.PAGE_END; //bottom of space
pane.add(btn_play_normal, gc);
gc.ipadx = 6;
gc.gridy = 1;;
gc.anchor = GridBagConstraints.PAGE_END; //bottom of space
gc.fill = GridBagConstraints.HORIZONTAL;
gc.ipady = 0; //reset to default
gc.weighty = 1.0; //request any extra vertical space
gc.anchor = GridBagConstraints.PAGE_END; //bottom of space
gc.insets = new Insets(10,0,0,0); //top padding
gc.gridx = 1; //aligned with button 2
gc.gridwidth = 2; //2 columns wide
gc.gridy = 2; //third row
pane.add(btn_play_ptr, gc);
爲了更好地幫助越早,張貼[SSCCE(http://sscce.org/)。 –
*「GridBagLayout元素不移動?」*添加'?'發表聲明並不是一個問題。我編輯了問題以添加一個。請[仔細查看更改](http://stackoverflow.com/posts/20568108/revisions)如果這是***不是你的問題,請添加一個你自己的! –