import java.awt.Color; import java.awt.Graphics; import java.awt.Polygon; import javax.swing.JFrame; /** * * @author cheknevis.blog.ir */ public class Shapes extends JFrame { public Shapes(){ super("Shapes - cheknevis.blog.ir"); setSize(600, 600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); } @Override public void paint(Graphics g){ super.paint(g); g.setColor(Color.blue); g.drawLine(50, 200, 150, 400); g.setColor(Color.red); g.drawRect(50, 55, 150, 50); g.setColor(Color.green); g.drawOval(100, 120, 150, 150); Polygon poly = new Polygon(); poly.addPoint(250, 55); poly.addPoint(250, 100); poly.addPoint(350, 100); g.drawPolygon(poly); poly.addPoint(500, 55); poly.addPoint(500, 100); poly.addPoint(350, 100); g.fillPolygon(poly); } public static void main(String[] args){ Shapes s = new Shapes(); s.setVisible(true); } }