我需要做一個循環與paintComponent
Java的塗料成份環
像這樣
public class Screen extends JComponent
{
public void paintComponent(Graphics g)
{
Graphics2D g2d = (Graphics2D) g;
g.fillOval(Main.x, Main.y, 20, 20);
}
{
for(int c = 0; c<10; c++)
{
paintComponent(g);
}
}
的方法是在擴展JComponent
類。
在for循環的Java給我一個錯誤
g
不能被解析爲一個變量
任何人都可以幫助嗎?
謝謝!
請問您可以發佈完整的代碼片段,例如'for'循環本身並不意味着什麼,周圍代碼在'for'循環中的位置會給我們更清晰的圖片 – 2015-04-02 11:07:59
我發佈了,這是一個非常小的類 – thevilcode 2015-04-02 11:13:49
它只是paintComponent方法和for循環 – thevilcode 2015-04-02 11:15:05