import javax.swing.*;		//contains JApplet, JLabel, JTextField
				//(parts of swing library)
				//graph. interface are in the swing components
import java.awt.*;		//contains Container
				//or creates a container (what is window in java).
				//awt: active window tool

import java.awt.event.*;	//contains  ActionListener


public class MyApplet extends JApplet implements ActionListener
{
						//(there is no main method in Applets)

	JLabel greeting = new JLabel("Hello world!");
	Font bigFont = new Font ("TimesRoman", Font.BOLD, 30);
	JTextField name = new JTextField(10);
	JButton click =new JButton("Click here");
	FlowLayout flow = new FlowLayout();

	public void init()
	{
		//first we need to create a container; then put labels or buttons in it
		Container con = getContentPane();
		greeting.setFont(bigFont);		//set label font
		con.setLayout(flow);		//set layout; must be before adding label, or button
						//(otherwise last component will replace the previous)
		con.add(greeting);			//add JLabel
		con.add(name);				//add JTextField
		con.add(click);				//add JButton
		click.addActionListener(this);
		name.addActionListener(this);
	}

	public void actionPerformed(ActionEvent thisEvent)
	{
		greeting.setText("Hi, " + name.getText());
	}
}

