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.*;
import java.awt.Graphics;

public class  Menu2 extends JFrame implements ListSelectionListener 
{
  Container c;
  shapeP sekil;
  JMenuBar menuBar;
  JMenu m1,m2;
  JPanel outputPanel;
  JList<String> sekillistesi;
  JList<String> renklistesi;
  String sekilisimleri[]={"Filled Star","Filled Ellipse"};
  String renkisimleri[]={"black","blue","cyan","dark gray","gray",
         "green","light grey","magenta","orange","pink","red","white","yellow"};
  Color renkler[]={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 Menu2()
  {    
	super("Menu Graphic controller");   
	int i=0;
	sekil=new shapeP(Color.black,i);
	renklistesi=new JList<String>(renkisimleri);
	renklistesi.setVisibleRowCount(5);
	sekillistesi=new JList<String>(sekilisimleri);
    c=getContentPane();
    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("Şekillerin hangi renkte olacağını seçer");    
    m1.add(new JScrollPane(renklistesi));    
    menuBar.add(m1);
    m2 = new JMenu("Shape List");  
    m2.setMnemonic('e');
    m2.getAccessibleContext().setAccessibleDescription("Şekillerin hangi şekil olacağını seçer");    
    m2.add(new JScrollPane(sekillistesi));
    menuBar.add(m2);   
    c.add(outputPanel,BorderLayout.CENTER);
    renklistesi.addListSelectionListener(this);
    sekillistesi.addListSelectionListener(this);
  }


public void valueChanged( ListSelectionEvent e)
{
if(e.getSource()==renklistesi)
{
Color r1=renkler[renklistesi.getSelectedIndex()];
sekil.setColor(r1);
}
if(e.getSource()==sekillistesi)
{sekil.setShape(sekillistesi.getSelectedIndex());}

repaint();
}

public static void main(String s[])
    {
        Menu2 f = new Menu2();
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        f.setSize(800,500);
        f.setVisible(true);        
    }
}
