1
没有人知道如何刷新我的JFrame
,所以我可以显示我的新JButton
?我的JFrame不刷新
private void displayGrid()
{
Case arrayGrid [][] = Grid.returnArray();
for(int i = 0; i < Settings.returnYGrid(); i++)
{
for(int j = 0; j < Settings.returnXGrid(); j++)
{
Case caase = arrayGrid [i][j];
panel.add(caase.getButton());
}
}
这里是我创建我的JFrame
时使用的方法。然后,我想刷新我的JFrame
用同样的方法,因为有些Case
我arrayGrid
已经改变,什么也没有发生在所有...
我试图设置revalidate()
,repaint()
并没有什么任。
嗨,感谢回答我的问题,但偏偏我更新已经尝试过这种方式,但仍然无法正常工作... –
您是否使用布局管理器? – MadProgrammer
@BenjaminClanet我添加了一个工作示例,问题必须是在您的代码中,您需要提供一个工作示例来演示您可以编译和运行的问题。尝试取出'panel.revalidate'和'panel.repaint'调用以查看差异 – MadProgrammer