import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class CheckBoxTestiSWF extends JFrame implements ItemListener
{
 private JTextField T;
 private JCheckBox Kalin,Italik;
 int KalinAyari=Font.PLAIN;;
 int ItalikAyari=Font.PLAIN;

 public CheckBoxTestiSWF()
 {
 super("check box örneği");
 Container c=getContentPane();
 c.setBackground(Color.lightGray);
 //c.setLayout(new FlowLayout());
 JPanel  Check=new JPanel();
 Check.setLayout(new GridLayout(0,1));
 //bos textField
 Kalin=new JCheckBox("Kalın");
 Kalin.setMnemonic('K');
 Kalin.setSelected(false);
 Kalin.addItemListener(this);
 Check.add(Kalin);
 Italik=new JCheckBox("İtalik");
 Italik.setMnemonic('İ');
 Italik.setSelected(false);
 Italik.addItemListener(this);
 Check.add(Italik);
 c.add(Check,BorderLayout.WEST);
 T=new JTextField("Buradaki yazının değişmesini izleyiniz");
 T.setFont(new Font("Serif",KalinAyari+ItalikAyari,20));
 c.add(T,BorderLayout.CENTER);
 }

 public void itemStateChanged(ItemEvent e)
 {
 Object kutu=e.getItemSelectable();
 if(Kalin==kutu && e.getStateChange()==ItemEvent.SELECTED)
   {KalinAyari=Font.BOLD;}
 else if(Kalin==kutu && e.getStateChange()==ItemEvent.DESELECTED)
   {KalinAyari=Font.PLAIN;}
 if(Italik==kutu && e.getStateChange()==ItemEvent.SELECTED)
   {ItalikAyari=Font.ITALIC;}
 else if(Italik==kutu && e.getStateChange()==ItemEvent.DESELECTED)
   {ItalikAyari=Font.PLAIN;}
 T.setFont(new Font("Serif",KalinAyari+ItalikAyari,20));
 }

 public static void main(String[] args)
 {
      CheckBoxTestiSWF pencere= new CheckBoxTestiSWF();
      pencere.addWindowListener(new BasicWindowMonitor());
      pencere.setSize(400,100);
      pencere.setVisible(true);
 }

}
