import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; public class LineArcEllipse extends JPanel { //A line is represented by the class java.awt.geom.Line2D Line2D theLine = new Line2D.Float(100, 10, 250, 100); //An arc is represented by the class java.awt.geom.Arc2D Arc2D theArc = new Arc2D.Float(20, 80, 200, 100, 90, 135, Arc2D.OPEN); //An ellipse is represented by the class java.awt.geom.Ellipse2D Ellipse2D theEllipse = new Ellipse2D.Float(100, 150, 100, 70); public static void main(String[] args) { JFrame f = new JFrame("LineArcEllipse"); f.setContentPane(new LineArcEllipse()); f.setSize(300, 300); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public void paintComponent(Graphics g) { super.paintComponent(g); //Do not forget this!!!! Graphics2D g2 = (Graphics2D)g; g2.draw(theLine); g2.draw(theArc); g2.fill(theEllipse); } }