import java.awt.*; import javax.swing.*; import java.awt.geom.*; public class FillArc extends JPanel { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // fill Arc2D g2.setPaint(Color.red); g2.fill(new Arc2D.Double(20, 20, 200, 100, 90, 180, Arc2D.OPEN)); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Fill Arc Example "); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBackground(Color.white); frame.setSize(300, 200); FillArc panel = new FillArc(); frame.add(panel); frame.setVisible(true); } }
$ java FillArc
Arc2D.Double: .../api/java/awt/geom/Arc2D.Double.html
Java example to fill Arc in Java. How to fill and arc using using Graphics2D? How do I draw an arc in Java 2D?
Arc
Arc 2D
Bar Chart
Circles and Ovals
Draw Text
Drawing Lines
Pie Chart 2D
Points
Polygon
Quadratic Curve
Rounded Edge Rectangle
Sine Wave
Squares and Rectangles