I'm trying to make a client chat application using Java
I want to transfer messages but Its seems like its not working.
Typing
is a JTextField
Button
is a button
(No way :O)
and ChatView
is the JTextArea
for sending messages between the clients
Leave the length()
its there so the button
doesn't accept spam.
Heres code
public void actionPerformed(ActionEvent e){
int x = Typing.getText().length();
if (x > 0) {
System.out.println(Typing.getText().length());
ChatView.insert("\n"+Typing.getText(),0);
Typing.setText("");}
try {
ServerSocket MainServer = new ServerSocket(344);
Socket Connect = MainServer.accept();
OutputStream outstream = Connect.getOutputStream();
PrintWriter out = new PrintWriter(Connect.getOutputStream());
out.print("Works");
} catch (Exception ee) {
System.err.print("/n"+"error");
}