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.*;


public class  control_boxP1 extends JPanel implements ActionListener,ItemListener
{
  JPanel inputPanel;
  JButton b;
  JTextField t;
  JCheckBox bold,italic;
  int red,green,blue;
  int normal_font,bold_font,italic_font;
  public Color renk;
  String s;
  
  public control_boxP1()
  {    
	s="Change the style of this writing";
	renk=Color.blue;
    inputPanel=new JPanel();
    inputPanel.setLayout(new GridLayout(4,1));
    b=new JButton("push button to change creen color");
    t=new JTextField(s);
    italic_font=Font.PLAIN;
	bold_font=Font.PLAIN;
	t.setFont(new Font("TimesRoman",bold_font+italic_font,14));
    bold=new JCheckBox("Bold");
    italic=new JCheckBox("Italic");    
    inputPanel.add(b,BorderLayout.NORTH);
    inputPanel.add(t);
    inputPanel.add(bold);
    inputPanel.add(italic); 
    add(inputPanel);
    b.addActionListener(this);
    italic.addItemListener(this);
    bold.addItemListener(this);
  }

public void itemStateChanged(ItemEvent e)
{   if(e.getSource()==bold)
    { if(e.getStateChange()==ItemEvent.SELECTED)
        {bold_font=Font.BOLD;}
      else
        {bold_font=Font.PLAIN;}
    }
    else if(e.getSource()==italic)
    { if(e.getStateChange()==ItemEvent.SELECTED)
        {italic_font=Font.ITALIC;}
      else
        {italic_font=Font.PLAIN;}
    }
    t.setFont(new Font("TimesRoman",bold_font+italic_font,14));
    repaint();
}


public void actionPerformed( ActionEvent e)
{
//tesadüfi renk belirle düğmeye her basılışta rengi değiştir.	
red=(int)(255.0*Math.random());
green  =(int)(255.0*Math.random());
blue   =(int)(255.0*Math.random());
renk=new Color(red,green,blue);
//input panelin rengini değiştiriyoruz
inputPanel.setBackground(renk);
//ana panelin rengini değiştiriyoruz
setBackground(renk);
//yazı kutusunun rengini değiştiriyoruz
t.setBackground(renk);
bold.setBackground(renk);
italic.setBackground(renk);
repaint();
}


}
