//Uses Label, Text field, buttons and a text area

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

// Use of Action listener for receiving action events
// When the action event happens , the objects actionPerformed method is invoked 

public class AreaButton extends Applet implements ActionListener
{
	private TextField one;
	private TextArea two;
	private Label label;
	private Font font;
	private Button button1;
	private Button button2;
	private Button button3;
	
	// method called by the browser of applt viewer
	// when an applet is going to be executed
	
	public void init()
	{
		String s = "Hello again. \nWelcme to the lesson";
		one = new TextField(25);
		two = new TextArea(5,50);
		
		font = new Font("TimesRoman", Font.PLAIN,12);
		label = new Label();
		// set label text
		label.setFont(font);
		
		button1 = new Button ("Copy");
		// add action listener to receive action events from comment in text field
		button1.addActionListener(this);
		
		button2 = new Button("Paste");
		// add action listener to receive action events from comment text field
		button2.addActionListener(this);
		
		button3 = new Button("Delete");
		// add action listener to receive action events from comment text field 
		button3.addActionListener(this);
		
		//add TextArea and button to the applet
		add(label);
		add(one);
		add(two);
		add(button1);
		add(button2);
		add(button3);
		
	}
	
	public void actionPerformed(ActionEvent e)
	{
		// checks if the button is pressed 
		if (e.getSource()==button1)
		{
			one.selectAll();
		}
		if (e.getSource()== button2)
		{
			
			if (one.getSelectionStart()!=one.getSelectionEnd())
			{
				two.setText(one.getSelectedText());
			}
		}
		if(e.getSource()==button3)
		{
			two.setText(null);
			one.setText(null);
		}
	}
}//end 					