Results 1 to 1 of 1
Thread: Chat Client using Smack API
- 05-01-2010, 02:40 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 9
- Rep Power
- 0
Chat Client using Smack API
Hi guys,
I am in the middle of creating a chat client, below is a list of what i've created so far:
--------------------------
-LoginUI: usernametxt....password and a login button
-MainUI: status of the user[available, away etc] and JTree which displays...users who are online.
-ChatUI: JTextArea for composing messages(composeBox) and JTextArea for displaying the messages send/received(convBox)
--------------------------------------------------------------
I am able to login using a valid information and show users who are online on a "JTree" in the MainUI. I can doubleClick on the user that i want to chat with, doing so will show the ChatUI.
But my main problem is that, if i want to chat with another user who is online on another client...using the ChatUI.
Here is the code that I am using:
----------------------------------------------------------------Java Code:public class ChatUI extends javax.swing.JFrame implements MessageListener { private LoginUI log = new LoginUI(); XMPPConnection connection = log.getConnection(); String msgLine; String msgTo; /** Creates new form ChatUI */ public ChatUI() { initComponents(); getContentPane().setBackground(java.awt.Color.white); } private void sendMessage(java.awt.event.ActionEvent evt) { //to be implented if(evt.getSource()==sendbtn){ msgLine = composeBox.getText(); while(msgLine != null){ sendMessage(msgLine, msgTo);[COLOR="Red"]<--msgTo: can't figure out how to get the user from the other class "MainUI"[/COLOR] } convBox.setText(msgLine); } public void sendMessage(String message, String to) throws XMPPException { Chat chat = connection.getChatManager().createChat(to, this); chat.sendMessage(message); } public void processMessage(Chat chat, Message msg) { if(msg.getType() == Message.Type.chat){ convBox.setText(chat.getParticipant() + " says: " + msg.getBody()); } } }
All i would like to know is...from the MainUI "JTree-which displays users who are online", once i double click on a user... how can i carry that user to the ChatUI class and use the same user to chat with him/her?
Pls help, as i've been trying this for long time...
P.S. I tried using the Netbeans console + buffereader/inputstreamreader to let the user type in the user that he/she want to talk to (by typing their full address i.e user@jabber.org) and that works fine but instead of using the console i wanted to use the interface...
Thanks in advance
Similar Threads
-
Need help with chat client
By the_flirt in forum NetworkingReplies: 4Last Post: 04-23-2010, 03:49 PM -
Chat Client
By Jessi34 in forum New To JavaReplies: 5Last Post: 12-09-2009, 03:49 PM -
Multithread Chat server/client
By gwaldarick in forum Advanced JavaReplies: 3Last Post: 09-19-2009, 12:22 AM -
[SOLVED] UDP chat client server
By Koren3 in forum NetworkingReplies: 2Last Post: 04-25-2009, 01:51 AM -
Help with chat client program
By srivigneshwar in forum New To JavaReplies: 1Last Post: 04-03-2009, 06:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks