new Ellipse2D.Double.(double x, double y, double w, double h) : Ellipse2D « java.awt.geom « Java by API






new Ellipse2D.Double.(double x, double y, double w, double h)

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

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

public class MainClass extends JPanel {

  public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    Ellipse2D e1 = new Ellipse2D.Double (20.0, 20.0, 80.0, 70.0);

    g2.setColor (Color.red);
    g2.fill (e1);

  
  }

  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.getContentPane().add(new MainClass());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200,200);
    frame.setVisible(true);
  }
}
           
       








Related examples in the same category