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

class dugmeresmi implements Icon
{
Color renk;
public dugmeresmi(Color c){renk=c;}
public int getIconWidth() {return 60;}
public int getIconHeight() {return 60;}
public void setPaint(Color c) {renk=c;}

public void paintIcon(Component c,Graphics g,int x,int y)
  {Graphics2D g2 = (Graphics2D)g;
   g2.setPaint(renk);
   Rectangle2D elips1=new Rectangle2D.Double(x,y,getIconWidth(),getIconHeight());
   g2.fill(elips1);
  }
}

public class dugme4 extends JApplet implements ActionListener,ItemListener
{
  Container c;
  JPanel inputPanel;
  JButton b;
  Icon sekil;
  int i;
  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 void init()
  {    
	i=0;
	sekil=new dugmeresmi(renkler[i]);
	c=getContentPane();
    inputPanel=new JPanel();
    b=new JButton("ekran renginideğiştirmek için düğme'ye basınız",sekil);
    inputPanel.add(b);
    c.add(inputPanel);
    b.addActionListener(this);
  }

public void itemStateChanged(ItemEvent ev)
{repaint();}


public void actionPerformed( ActionEvent e)
{
inputPanel.setBackground(renkler[i++]);repaint();
i%=13;
}

    public static void main(String s[])
    {
        JFrame f = new JFrame("Grafik ekran düğme kontrol programı");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new dugme4();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(800,400));
        f.setVisible(true);
    }
}





