1import java.awt.BorderLayout;
2import java.awt.event.ActionEvent;
3import java.awt.event.ActionListener;
4
5import javax.swing.JButton;
6import javax.swing.JFrame;
7import javax.swing.JTextArea;
8
9public class Foo{
10
11 public static void main(String[] args) {
12
13 JFrame f = new JFrame("A JFrame");
14 f.setSize(250, 250);
15 f.setLocation(300,200);
16 final JTextArea textArea = new JTextArea(10, 40);
17 f.getContentPane().add(BorderLayout.CENTER, textArea);
18 final JButton button = new JButton("Click Me");
19 f.getContentPane().add(BorderLayout.SOUTH, button);
20 button.addActionListener(new ActionListener() {
21
22 @Override
23 public void actionPerformed(ActionEvent e) {
24 textArea.append("Button was clicked\n");
25
26 }
27 });
28
29 f.setVisible(true);
30
31 }
32
33}