package examples.example5_chat_OO_library; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; /** *
 * A simple Chat window for 2 users to chat.
 * It:
 *   -- Shows what the other Chatter just said
 *   -- Has a text box for you to enter what you want to say.
 *   
 * When you press the Go button, your message is sent to the other Chatter.
 * Sometime thereafter, you get whatever the other Chatter responds.
 * 
 * Send BYE to stop the protocol and exit.
 * 
* * @author David Mutchler, using examples.example1_one_client from the Java Tutorials. May, 2009. */ public class Chatter extends JFrame { /** * Displays a pair of text areas: one for what the other Chatter just said, * and one for what you are about to say. * Also a Go button to send your chat to the other Chatter * and pause to receive a response. * @param label */ public Chatter(String label) { this.setSize(900, 300); this.setTitle("Chat Demo"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel otherChatterLabel = new JLabel(label); JTextArea otherChatterTextArea = new JTextArea(5, 60); JPanel otherChatterPanel = new JPanel(); otherChatterPanel.add(otherChatterLabel); otherChatterPanel.add(otherChatterTextArea); this.add(otherChatterPanel); this.setVisible(true); } }