Java program to draw a Curve using Graphics2D class
KW.java
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
class KW extends Frame
{
    Stroke s=new BasicStroke(5);
    QuadCurve2D curve=new QuadCurve2D.Double(320,50,200,500,50,50);
    public void paint(Graphics g) 
    {
        Graphics2D ga=(Graphics2D)g;
        ga.setStroke(s);
        ga.setPaint(Color.blue);
        ga.draw(curve);
    }
    public static void main(String args[]) 
    {
        Frame frame=new KW();
        frame.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
        frame.setSize(400,300);
        frame.setVisible(true);
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW
Advertisement