我使用Eclipse,我想使圖形行成的JFrame通過下面的代碼:如何在JFrame中生成圖形行?
public void Makeline() {
Graphics g=new Graphics(); // has error
Graphics2D g2 = (Graphics2D) g;
g2.draw(new Line2D.Double(0, 0, 20, 20));
}
但給跟隨着錯誤:
Cannot instantiate the type Graphics
圖形是抽象的,你必須擴展它實現所需的方法。 – DSquare