Java Applet面板刷新

Java Applet面板刷新

问题描述:

我有一个Java Applet,它可以从URL加载棋盘游戏的记录,并使用一系列以网格形式排列并嵌套在JPanel中的面板来显示配置.这是带有文本字段以及用于输入和输出的整个applet的一小部分.当按下按钮时,我希望控制板显示记录中的下一个配置.我想出了一种方法来执行此操作,但是当按下按钮时,会显示相同的配置,但是当我向上或向下滚动或调整窗口大小时,配置就会更改.当按下按钮时,是否有办法仅刷新板JPanel?当前,当按下按钮时,将创建新的配置面板,删除旧的配置,并将新的配置添加到显示.

I have a Java Applet that loads a record of a board game from a URL and displays the configuration using a series of panels laid out in a grid and nested in a JPanel. This is a small component of an overall applet with text fields and such for inputs and outputs. When a button is pressed, I want the board to show the next configuration from the record. I figured out a way to do this, but when the button is pressed, the same configuration is shown, but when I scroll up or down, or resize the window, then the configuration changes. Is there a way to "refresh" just the board JPanel when the button is pressed? Currently, when the button is pressed, the new configuration panel is created, the old configuration is removed, and the new configuration is added to the display.

非常感谢!

如果没有其他问题,您可以尝试隐藏然后立即再次显示面板.那应该迫使它重画.

If nothing else, you could try hiding and then immediately showing the panel again. That should force it to redraw.