Java Graphics How to - Draw an arc outline








Question

We would like to know how to draw an arc outline.

Answer

import java.awt.Color;
import java.awt.Graphics;
/*  w  ww .java2 s. co m*/
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainClass extends JPanel {

  public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setSize(400, 400);
    f.add(new MainClass());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }

  public void paint(Graphics g) {
    g.setColor (Color.yellow);  
    g.drawArc (5, 15, 50, 75, 25, 165); 
  }
}