import java.awt.event.*;
import java.awt.*;
import java.applet.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.*;
import java.util.*;
import java.awt.Font;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class appleted extends Applet implements ActionListener
{
TextArea t;
Button copy,cut,paste;
// String[] description = { "Courier", "Sans Serif",
//"Monospaced","Symbol" };
String selection;
private JComboBox fontComboBox;
public void FontComboBox()
{
// setTitle("ComboBoxTest");
// setSize(300, 200);
//fontComboBox.addActionListener(this);
/* JPanel p = new JPanel();
p.add(fontComboBox);
getContentPane().add(p, "North");
getContentPane().add(fontLabel, "Center");*/
this.validate();
}
public void init()
{
setBackground(Color.white);
t=new TextArea(10,40);
add(t);
copy=new Button("copy");
add(copy);
copy.addActionListener(this);
cut=new Button("cut");
add(cut);
cut.addActionListener(this);
paste=new Button("paste");
add(paste);
paste.addActionListener(this);
fontComboBox = new JComboBox();
fontComboBox.setEditable(true);
fontComboBox.addItem("Serif");
fontComboBox.addItem("SansSerif");
fontComboBox.addItem("Monospaced");
fontComboBox.addItem("Dialog");
fontComboBox.addItem("DialogInput");
fontComboBox.addActionListener(this);
this.validate();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==cut) cutAction();
else if (e.getSource()==copy) copyAction();
else if (e.getSource()==paste) pasteAction();
this.validate();
}
private void copyAction()
{
selection=t.getSelectedText();
}
private void cutAction()
{
int start=t.getSelectionStart(),
end=t.getSelectionEnd();
selection=t.getSelectedText();
t.replaceRange("",start,end);
t.setSelectionEnd(start);
}
private void pasteAction()
{
int start=t.getSelectionStart(),
end=t.getSelectionEnd();
t.replaceRange(selection,start,end);
}
}