Drawing an arc in Swing

Use the method drawArc that accepts the left and right coordinate, the height and width of the circle, the angle of the starting point and the angle of the arc. In this example, an arc is drawn from 90 degrees for 45 degrees.


import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame {
   public Main() {
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
   public void paint(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;
      g2d.drawArc(10, 50, getSize().width-20, getSize().height-50, 90, 45);
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(100, 100);