import java.util.* ; import java.io.* ; import java.awt.* ; import java.awt.event.* ; import javax.swing.* ; import javax.swing.event.* ; class TerminationListener implements WindowListener { public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { System.exit(0) ; } public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} } class TextAreaPanel extends JPanel implements DocumentListener { public TextAreaPanel() { edit = new JTextArea(8, 15) ; edit.getDocument().addDocumentListener(this) ; edit.setLineWrap(true) ; add(new JScrollPane(edit, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)) ; } public void changedUpdate(DocumentEvent evt) { } public void insertUpdate(DocumentEvent evt) { updated = true ; } public void removeUpdate(DocumentEvent evt) { updated = true ; } private JTextArea edit ; private boolean updated = false ; } public class TextAreaTest { public static void main(String [] args) { JFrame frame = new JFrame() ; frame.setTitle("TextArea") ; frame.setSize(450, 300) ; frame.addWindowListener(new TerminationListener()) ; frame.getContentPane().add(new TextAreaPanel()) ; frame.setVisible(true) ; } }