FileDocCategorySizeDatePackage
SimpleChatClientA.javaAPI DocExample1747Sat Jan 08 12:06:56 GMT 2005None

SimpleChatClientA

public class SimpleChatClientA extends Object

Fields Summary
JTextField
outgoing
PrintWriter
writer
Socket
sock
Constructors Summary
Methods Summary
public voidgo()

        JFrame frame = new JFrame("Ludicrously Simple Chat Client");
        JPanel mainPanel = new JPanel();

        outgoing = new JTextField(20);
 
        JButton sendButton = new JButton("Send");
        sendButton.addActionListener(new SendButtonListener());
       
        
        mainPanel.add(outgoing);
        mainPanel.add(sendButton);
        
        setUpNetworking();
     ;
          
        frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
        frame.setSize(400,500);
        frame.setVisible(true);                
   
     
public static voidmain(java.lang.String[] args)

       SimpleChatClientA client = new SimpleChatClientA();
       client.go();
    
private voidsetUpNetworking()

  
        try {
           sock = new Socket("127.0.0.1", 5000);
          
           writer = new PrintWriter(sock.getOutputStream());
          
           System.out.println("networking established");
        } catch(IOException ex) {
           ex.printStackTrace();
        }