繼續收到這些找不到符號錯誤。我知道它涉及的圖片類和它的方法,但我知道他們在那裏,但我的編譯器無法識別它們。有任何想法嗎?發現在java中顯示問題,找不到符號錯誤
import java.awt.Color;
import java.awt.Graphics;
public class DispTest
{
private Picture display;
private Graphics graphics;
public DispTest()
{
display = new Picture(500,500);
graphics = display.getGraphics();
for(int x = 0; x < display.getWidth(); x++) {
for(int y = 0; y < display.getHeight(); y++) {
display.getPixel(x,y).setColor(new Color(123,204,246));
if((x > 0 && x % 50 == 0) || (y > 0 && y % 50 == 0))
display.getPixel(x,y).setColor(new Color(44,72,39));
}
}
graphics.setColor(new Color(44,72,39));
for(int x = 10; x < display.getWidth(); x += 50)
for(int y = 10; y < display.getHeight(); y += 50)
graphics.drawOval(x,y,30,30);
display.show();
}
public static void main(String [] args)
{
DispTest dt = new DispTest();
}
}
5個錯誤:
File: C:\Users\Andrew\SoftwareDevelopment\DispTest.java [line: 22]
Error: cannot find symbol
symbol: method getGraphics()
location: variable display of type Picture
File: C:\Users\Andrew\SoftwareDevelopment\DispTest.java [line: 25]
Error: cannot find symbol
symbol: method getPixel(int,int)
location: variable display of type Picture
File: C:\Users\Andrew\SoftwareDevelopment\DispTest.java [line: 27]
Error: cannot find symbol
symbol: method getPixel(int,int)
location: variable display of type Picture
File: C:\Users\Andrew\SoftwareDevelopment\DispTest.java [line: 32]
Error: cannot find symbol
symbol: method getWidth()
location: variable display of type Picture
File: C:\Users\Andrew\SoftwareDevelopment\DispTest.java [line: 33]
Error: cannot find symbol
symbol: method getHeight()
location: variable display of type Picture
你是什麼意思「我知道的圖片類有」?他們在哪?我認爲這是你寫的一堂課。編譯這個之前編譯過Picture.java嗎? – 2013-05-03 22:21:44
我相信圖片類被包含在awt中,但並不確定。 – LongForde 2013-05-03 22:36:39
檢查可用的awt類[此處](http://docs.oracle.com/javase/6/docs/api/java/awt/package-summary.html)。 – Voicu 2013-05-03 22:38:20