import javax.swing.*; import java.awt.event.*; import java.awt.*; class ChatFrame extends JFrame implements ActionListener { private JTextField input; private JTextArea output; public ChatFrame() { super(); input = new JTextField(20); output = new JTextArea(20,20); output.setLineWrap(true); output.setWrapStyleWord(false); input.addActionListener(this); getContentPane().setLayout(new FlowLayout()); getContentPane().add(input); getContentPane().add(output); } public void actionPerformed(ActionEvent e ) { output.append(input.getText()); } public static void main(String args[]) { ChatFrame fra = new ChatFrame(); fra.setBounds(0,0,400,400); fra.setVisible(true); fra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }