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  JScrollPaneTest extends JApplet implements ItemListener
{
  JPanel inputPanel;
  JTextField t;
  JCheckBox bold,italic;
  int normal_font,bold_font,italic_font;
  String s;
  public void init()
  {    
	s="Change the style of this writing";
    inputPanel=new JPanel();
    t=new JTextField(s,40);
    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(t);
    inputPanel.add(bold);
    inputPanel.add(italic); 
    add(new JScrollPane(inputPanel));
    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 static void main(String s[])
    {
        JFrame f = new JFrame("control box graphic controller");
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        JApplet applet = new JScrollPaneTest();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.setSize(800,500);
        f.setVisible(true); 
    }
}
