【发布时间】:2015-04-14 02:09:06
【问题描述】:
我正在尝试使用 GridBagLayout 删除 JPanel 中的多个组件
javax.swing.SwingUtilities.invokeLater(new Runnable(){
public void run(){
createAndShowGUI();
GamePanel gamePanel = new GamePanel(frame.getContentPane());
gamePanel.delBlock(0, 0);
gamePanel.delBlock(0, 1);
frame.setContentPane(gamePanel);
}
});
这是删除区块的方法
public void delBlock(int x, int y){
int location = x * row + y;
this.remove(location);
this.revalidate();
this.repaint();
}
如您所见,这 2 个块应该彼此相邻,但这就是我得到的结果。
【问题讨论】:
-
您的图片没有通过链接显示
标签: java swing user-interface gridbaglayout