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  Menu1 extends JFrame implements ListSelectionListener 
{
  JPanel inputPanel;
  JList<String> colorlist;
  JMenuBar menuBar;
  JMenu m1,m2;
  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 Menu1()
  { 
	super("Menu Graphic controller");   
    inputPanel=new JPanel();
	colorlist=new JList<String>(colornames);
    colorlist.setVisibleRowCount(10);
    colorlist.addListSelectionListener(this);
    menuBar=new JMenuBar();
	setJMenuBar(menuBar);
	m1 = new JMenu("Color List");
    m1.setMnemonic('M');
    m1.getAccessibleContext().setAccessibleDescription("Programdaki sadece bu Menunun alt listeleri mevcuttur");    
    m1.add(new JScrollPane(colorlist));    
    menuBar.add(m1);
    m2 = new JMenu("Second List");  
    menuBar.add(m2);   
    add(inputPanel);    
  }


public void valueChanged( ListSelectionEvent e)
{
Color r1=colors[colorlist.getSelectedIndex()];
inputPanel.setBackground(r1);
}

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