Exemplo 1 – Primitivas Geométricas
private void draw(Graphics g)
{
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(new Color(0, 134, 0));
g2d.fill(new Rectangle2D.Double(100, 100, 600, 400));
int x1Points[] = {120, 400, 680, 400};
int y1Points[] = {300, 120, 300, 480};
g2d.setColor(new Color(252, 252, 0));
g2d.fillPolygon(new Polygon(x1Points, y1Points, 4));
g2d.setColor(new Color(0, 0, 140));
g2d.fill(new Ellipse2D.Double(280, 180, 240, 240));
}