I am writing a RMI chat program. In my program I am able to receive and send messages, but i am not able to display it in the TextArea. I am not sure what is the error. I tried using Event Dispatch method also. It doesn't help.
public class client extends javax.swing.JFrame implements inter {
public client() {
    initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    try {
        final inter i = (inter) Naming.lookup("rmi://localhost:1111/client1");
        final String msg = jTextField1.getText();
        if (msg.length() > 0) {
            jTextArea1.append("Me :" + msg);
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        i.rcvMsg("Client 1 : " + msg);
                    } catch (RemoteException ex) {
                    }
                }
            });
        }
    } catch (RemoteException ex) {
     } catch (NotBoundException ex) {
     } catch (MalformedURLException ex) {
     }
}                                        
 public void rcvMsg(String msg) {
    final String s = msg;
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            System.out.println("server called");
            System.out.println(s);
            jTextArea1.append(s);
            System.out.println("client msg" + java.awt.EventQueue.isDispatchThread());
            jTextArea1.update(jTextArea1.getGraphics());
        }
    });
}
public static void main(String args[]) {
    try {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new client().setVisible(true);
            }
        });
        client c2 = new client();
        inter stub = (inter) UnicastRemoteObject.exportObject(c2, 0);
        Registry registry = LocateRegistry.createRegistry(1113);
        registry.bind("client2", stub);
    } catch (AlreadyBoundException ex) {
    } catch (AccessException ex) {
    } catch (RemoteException ex) {
    }
}
}
Please help...
 
     
     
    