import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.Rectangle;
import java.awt.geom.Ellipse2D;
import javax.swing.JComponent;
/**
* object of class myComponent provide a "canvas" to record your art work.
*
* @author (Kevin Knapp)
* @version (9-27-13)
*/
public class MyComponent extends JComponent
{
/**
* method used in awt to "paint" on the component
*
* @param g graphics used to "paint" with
* @return none
*/
public void paintComponent(Graphics g)
{
// declares the 2D Graphics object and a Rectangle
Graphics2D g2;
Ellipse2D.Double outerFace = new Ellipse2D.Double(100,150,300,350);
Line2D.Double mouth = new Line2D.Double(200,400,300,400);
Ellipse2D.Double leftOuterEye = new Ellipse2D.Double(150,275,50,50);
Ellipse2D.Double rightOuterEye = new Ellipse2D.Double(250,275,50,50);
Ellipse2D.Double leftPupil = new Ellipse2D.Double(150,285,25,25);
Ellipse2D.Double rightPupil = new Ellipse2D.Double(250,285,25,25);
Line2D.Double leftEyeLine = new Line2D.Double(150,300,200,300);
Line2D.Double rightEyeLine = new Line2D.Double(250,300,300,300);
leftPupil.fillArc(75, 100, 200, 200, 90, 270);
rightPupil.fillArc(75, 100, 200, 200, 90, 270);
g2 = (Graphics2D) g;
g2.draw(outerFace);
g2.draw(mouth);
g2.draw(leftOuterEye);
g2.draw(rightOuterEye);
g2.draw(leftPupil);
g2.draw(rightPupil);
g2.draw(leftEyeLine);
g2.draw(rightEyeLine);
}
}
所以我认为错误意味着fillArc不是我导入的类中列出的方法,但是我检查了API及其那里,我也检查了类的拼写,所以Idk是什么做
我为眼睛的瞳孔设置圆圈作为我想要填充的弧线的参考点,但我甚至无法使用定位,直到我得到一些东西出现。
答案 0 :(得分:0)
fillArc()
课程中没有Ellipse2D.Double
方法。您可能应该在Graphics
对象上调用此方法:
g.fillArc(75, 100, 200, 200, 90, 270);