here is you program 3,but it is JFrame,you should read about how to make Applets and change some code
import javax.swing.*;
import java.awt.event.*;
public class Frame extends JFrame{
private JButton addText=new JButton("Add text");
private JTextArea textArea=new JTextArea();
private JTextField textField=new JTextField("");
public Frame(String name){
super(name);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.getContentPane().add(this.addComponents());
this.setSize(200,300);
this.setVisible(true);
}
private JPanel addComponents(){
JPanel p=new JPanel();
p.setLayout(new BoxLayout(p,BoxLayout.Y_AXIS));
p.add(textField);
p.add(addText);
p.add(textArea);
addText.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
textArea.append(textField.getText()+"\n");
textField.setText("");
}
});
return p;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Frame("My prog");
}
}