Java AWT Arc2D class

Description

Java AWT Arc2D class


import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Arc2D;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends JPanel {
  @Override/*from  www.  j ava  2  s  .co  m*/
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g; // cast g to Graphics2D

    // draw 2D pie-shaped arc in white
    g2d.setPaint(Color.WHITE);
    g2d.setStroke(new BasicStroke(6.0f));
    g2d.draw(new Arc2D.Double(240, 30, 75, 100, 0, 270, Arc2D.PIE));
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame("Drawing 2D shapes");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Main Main = new Main();
    frame.add(Main);
    frame.setSize(425, 200);
    frame.setVisible(true);
  }
}



PreviousNext

Related