This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes help with updating a JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "help with updating a JList" Watch "help with updating a JList" New topic
Author

help with updating a JList

Shanna Ripley
Greenhorn

Joined: Mar 12, 2010
Posts: 18
Hi All

For my first java project, I'm attempting to develop my own instant messenger type program. I have my client and server sockets set up ok and the server can accept multiple clients. My next step is to try and send private messages to selected clients. What I am trying to do is when a client connects to the server, the clients name, port and ip address will be displayed in a JList on my gui. I have my JList on my gui but my problem comes with trying to update the list when a new client is connected.
I have several classes...
MyClient.java: creates client gui and sends connection to MyServer.java
MyServer.java: This is my server. It accepts connection from client and creates a ConnectionHandler to handle each connection by each client.
UsersGroup.java: This class maintains info about the clients. Adds User objects to a vector to keep track of which clients are online.
Users.java: Stores info about each client, e.g. ip address, port
ConnectionHandler.java: An instance is created to handle each client connection. Details about client are stored in a UsersGroup object. And monitors msgs incoming to server.
IncomingChat.java: This class monitors the input to the client from the server and displays the message to MyClients gui.

Does anyone have any idea how I would go about this??? If you need to view any of the code, let me know. I thought posting all those classes would be a bit much but if it's needed just let me know

Thanks in advance
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

Recommended reading http://java.sun.com/docs/books/tutorial/uiswing/components/list.html#mutable


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Shanna Ripley
Greenhorn

Joined: Mar 12, 2010
Posts: 18


Thanks for that but I was hoping someone could lend a hand with how to get the info about the current clients back to be displayed on the gui. i.e how to get the instances of the Users objects stored in the UsersGroup object back to MyClient class. I hope this makes sense and that I'm explaining it properly
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
whenever a user object is created it needs a reference to the JList's model,
so it can be added to that model
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with updating a JList
 
Similar Threads
Sending a message to a remote server
Test Clarifcation
Don't understand mode flag
Chat Programming.
java.net Socket port number question