import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ChatApplication {
	JFrame frame;
	JTextArea textArea;
	JPanel panel;
	JLabel messageL;
	JTextField message;
	JButton enter;
	
	ChatApplication() {
		frame = new JFrame("Chat Application");
		textArea = new JTextArea();
		panel = new JPanel();
		messageL = new JLabel("Message");
		message = new JTextField(50);
		enter = new JButton("Enter");
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		textArea.setEditable(false);
		
		panel.add(messageL);
		panel.add(message);
		panel.add(enter);
		frame.add(panel, BorderLayout.SOUTH);
		frame.add(textArea, BorderLayout.CENTER);
		
		EnterListener enterL = new EnterListener();
		enter.addActionListener(enterL);
		
		frame.setSize(800, 600);
		frame.setVisible(true);
	}
	
	class EnterListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			String text = message.getText();
			textArea.append("Swap says: " + text + "\n");
			message.setText("");
		}
	}
	
	public static void main(String args[]) {
		ChatApplication chat = new ChatApplication();
	}
}

