Ajuda em Chat

IDE : NetBeans 6.5.1

O problema é o seguinte, crio o servidor, os varios utilizadores ligam-se ao servidor ocupando a mesma sala, mas depois quando quero comunicar em privado (um utilizador a falar com outro em privado) nao funciona, a janela da conversacao abre-se, consigo enviar o texto, mas o outro nao recebe a mensagem :
alguem me pode ajudar?

Podiam-me tambem dizer como substituo strings (ex: “:)” por uma imagem com um sorriso?

Obrigado :slight_smile:

O ficheiro esta aqui para download : http://www.2shared.com/file/6250834/ef43e204/RmiBiExample.html ou em anexo :slight_smile:

Se alguem tiver um chat em que faça o mesmo que faça o meu e que me possa arranjar agradecia muito tambem :slight_smile:

Não cheguei a olhar o teu fonte, mas só queria lhe mostrar uma outra opção de ferramenta:
http://www.adobe.com/devnet/flex/tourdeflex/web/# na árvore da esquerda vá em Flex Data Access > Messaging Service > Chat.
Com Flex + BlazeDS + Java, vc terá uma interface RIA e pelo q vi terá muito menos código para fazer o q precisa.

[]s

[code]public class Privado extends javax.swing.JFrame {

//who's the user
static String username;

//mother
static RmiExampleClient ec;

//return username
public String getUsername(){
    return(username);
}

//receive message
public void receiveMessage(String message) {

    chatArea.append(username + ": " + message);
}

/** Creates new form Privado */
public Privado(String username, RmiExampleClient ec) {
    this.username = username;
    this.ec = ec;
    initComponents();
}

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    ControlPanel3 = new javax.swing.JPanel();
    msgArea = new javax.swing.JTextField();
    sendButton = new javax.swing.JButton();
    jPanel2 = new javax.swing.JPanel();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    jScrollPane2 = new javax.swing.JScrollPane();
    chatArea = new javax.swing.JTextArea();
    jPanel4 = new javax.swing.JPanel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Privado");

    ControlPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

    msgArea.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
    msgArea.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            msgAreaKeyPressed(evt);
        }
    });

    sendButton.setText("Send"); // NOI18N
    sendButton.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            sendButtonMouseClicked(evt);
        }
        public void mousePressed(java.awt.event.MouseEvent evt) {
            sendButtonMousePressed(evt);
        }
    });
    sendButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            sendButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout ControlPanel3Layout = new javax.swing.GroupLayout(ControlPanel3);
    ControlPanel3.setLayout(ControlPanel3Layout);
    ControlPanel3Layout.setHorizontalGroup(
        ControlPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(ControlPanel3Layout.createSequentialGroup()
            .addComponent(msgArea, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(18, 18, 18)
            .addComponent(sendButton, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(21, Short.MAX_VALUE))
    );
    ControlPanel3Layout.setVerticalGroup(
        ControlPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(ControlPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
            .addComponent(msgArea, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
            .addComponent(sendButton, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
    );

    jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

    jTabbedPane1.setFocusable(false);

    chatArea.setColumns(20);
    chatArea.setEditable(false);
    chatArea.setRows(5);
    chatArea.setWrapStyleWord(true);
    chatArea.setFocusable(false);
    jScrollPane2.setViewportView(chatArea);

    jTabbedPane1.addTab("Chat", jScrollPane2);

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
    );

    jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 90, Short.MAX_VALUE)
    );
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 177, Short.MAX_VALUE)
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 592, Short.MAX_VALUE)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(ControlPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(14, 14, 14)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap()))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 291, Short.MAX_VALUE)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ControlPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
    );

    pack();
}// </editor-fold>                        

private void msgAreaKeyPressed(java.awt.event.KeyEvent evt) {                                   
    //if it is the enter key, then send the message

}

private void sendButtonMousePressed(java.awt.event.MouseEvent evt) {                                        

}

private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
 
}                                          

private void sendButtonMouseClicked(java.awt.event.MouseEvent evt) {                                        

    //call send message
    try{
        ec.callreceivePrivateMsg(username, msgArea.getText());
    }
    catch(Exception e){

    }

}                                       

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
           try {
                javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
           }catch (Exception e) {System.out.println(e);}

           new Privado(username, ec).setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JPanel ControlPanel3;
private javax.swing.JTextArea chatArea;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTextField msgArea;
private javax.swing.JButton sendButton;
// End of variables declaration                   

}[/code]

o problema está aqui :
Falta alguma coisa para abrir a janela no host2 com a mensagem recebida.
Alguem me pode ajudar?
Obrigado :slight_smile: