I generally use an inner class when working with listeners. Otherwise
the new event model didn't do very much to improve on the old AWT
method.
Modified:
import java.awt.*;
import java.applet.*;
import java.util.*;
import java.awt.event.*;
/*
<applet code = "MessageWindow" width=400 height = 200>
</applet>
*/
public class MessageWindow extends Applet
{
Button Send;
TextArea A1, A2;
public void init ()
{
setBackground (Color.cyan);
setLayout (new BorderLayout ());
add (new TextArea (" ", 10, 30), BorderLayout.NORTH);
add (new TextArea (" ", 5, 30), BorderLayout.SOUTH);
// I put this
Send = new Button ("Send");
//I change dis:)
add (Send, BorderLayout.WEST);
Send.addActionListener (new Listen ());
}
class Listen implements ActionListener
{
public void actionPerformed (ActionEvent ae)
{
repaint ();
}
}
}