import java.io.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.geom.*;


public class  star extends JApplet implements ListSelectionListener 
{
  starP sekil;
  JMenuBar menuBar;
  JMenu m1,m2;
  JPanel outputPanel;
  JList sekilList;
  JList colorList;
  String sekilNames[]={"three sided star","four sided star","five sided star",
  "six sided star","seven sided star","eight sided star","nine sided star","ten sided star"};
  String colorNames[]={"black","blue","cyan","dark gray","gray",
         "green","light grey","magenta","orange","pink","red","white","yellow"};
  Color colors[]={Color.black,Color.blue,Color.cyan,Color.darkGray,Color.gray,
	     Color.green,Color.lightGray,Color.magenta,Color.orange,Color.pink,
	     Color.red,Color.white,Color.yellow};
  
  public void init()
  {    
	int i=3;
	sekil=new starP(Color.black,i);
	colorList=new JList(colorNames);
	colorList.setVisibleRowCount(4);
	sekilList=new JList(sekilNames);
	sekilList.setVisibleRowCount(4);
    outputPanel=new JPanel();
    outputPanel.setLayout(new BorderLayout());
    outputPanel.add(sekil,BorderLayout.CENTER);
    menuBar=new JMenuBar();
	setJMenuBar(menuBar);
	m1 = new JMenu("Color List");
    m1.setMnemonic('R');
    m1.getAccessibleContext().setAccessibleDescription("Starların hangi colorte olacağını seçer");    
    m1.add(new JScrollPane(colorList));    
    menuBar.add(m1);
    m2 = new JMenu("Star List");  
    m2.setMnemonic('Y');
    m2.getAccessibleContext().setAccessibleDescription("Starların kaç köşeli olacağını seçer");    
    m2.add(new JScrollPane(sekilList));
    menuBar.add(m2);   
    add(outputPanel,BorderLayout.CENTER);
    colorList.addListSelectionListener(this);
    sekilList.addListSelectionListener(this);
  }


public void valueChanged( ListSelectionEvent e)
{
if(e.getSource()==colorList)
{
Color r1=colors[colorList.getSelectedIndex()];
sekil.setColor(r1);
}
if(e.getSource()==sekilList)
{sekil.setside(sekilList.getSelectedIndex()+3);}
repaint();
}

    public static void main(String s[])
    {
        JFrame f = new JFrame("Star control program push mouse and drag to draw");
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        JApplet applet = new star();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(545,400));
        f.setVisible(true);
    }

}
