import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class shapeP extends JPanel
{   
Color c;
int shape;
//shape = 0 ellipse
//shape = 1 star

public shapeP(Color c1,int shape1)
{c=c1;shape=shape1;}

public void setColor(Color c1)
{c=c1;}

public void setShape(int shape1)
{shape=shape1;}

public void paintComponent(Graphics g)
{
super.paintComponent(g);
if(shape==0)
{	
int x[]={55,67,109,73,83,55,27,37,1,43};
int y[]={0,36,36,54,96,72,96,54,36,36};
Graphics2D g2=(Graphics2D)g;
GeneralPath star=new GeneralPath();
star.moveTo(x[0],y[0]);
for(int i=1;i<x.length;i++)
   {star.lineTo(x[i],y[i]);}
star.closePath();
g2.setColor(c);  
g2.fill(star);
}
else if(shape==1)
{
     Graphics2D g2=(Graphics2D)g;	 
     g2.setFont(new Font("Serif",Font.BOLD,24));	 
     g2.setColor(c);
     g2.setStroke(new BasicStroke(2.0f));
     Ellipse2D x=new Ellipse2D.Double(50,50,500,200);
     g2.fill(x);  
}
}
}
