There are two ways to fill basic shapes like lines and rectangles.
#有两种方法来填充基本图形,像线和矩形
The first is to use specific drawing methods like Graphics.fillOval().
#第一种方法是使用特殊的画图方法,比如Graphics.fillOval()方法
This example uses these methods.
#这个例子试用了这些方法。
The second is to construct ashape and then use Graphics2D.fill() to fill the shape.
#第二个方法是构造一个图像,并且使用Graphics2D.fill()方法来填充图形
See thejava.awt.geom package for examples that create shapes.
#看java.awt.geom包,里面有很多关于创建图形的示例
g2d.fillArc(x, y, w, h, startAngle, arcAngle);
g2d.fillOval(x, y, w, h);
g2d.fillRect(x, y, w, h);
g2d.fillRoundRect(x, y, w, h, arcWidth, arcHeight);
Polygon polygon = new Polygon();
polygon.addPoint(x, y);
// ...continue adding points
g2d.fillPolygon(polygon);