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 及其那里,我还检查了类的拼写,所以我知道该怎么做
我有眼睛瞳孔的圆圈作为我想要填充的弧线的参考点,但我什至不能玩定位,直到我得到一些东西来显示。