Java tutorial
import java.awt.BasicStroke; import java.awt.Color; import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import javax.swing.JComponent; import javax.swing.JFrame; public class MainClass { public static void main(String[] args) { JFrame jf = new JFrame("Demo"); Container cp = jf.getContentPane(); MyCanvas tl = new MyCanvas(); cp.add(tl); jf.setSize(300, 200); jf.setVisible(true); } } class MyCanvas extends JComponent { public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setPaint(Color.black); g2.setStroke(new BasicStroke(8)); g2.draw(new Ellipse2D.Double(20, 20, 50, 50)); } }