-1
有人可以向我解釋爲什麼我需要在此代碼中使用repaint()
方法嗎? 如果我不這樣做,我得到一個錯誤stackoverflow
Java paint()方法溢出
private class GamePanel extends JPanel
{
public void paint(Graphics g)
{
super.paint(g);
onPaint(g);
}
}
protected void onPaint(Graphics g)
{
frameRate.calculate();
g.setColor(Color.WHITE);
g.drawString(frameRate.getFrameRate(),30,30);
repaint();
}
爲了儘快提供更好的幫助,請發佈[MCVE]或[簡短,獨立,正確的示例](http://www.sscce.org/)。 –