File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "help with updating a JList" Watch "help with updating a JList" New topic

help with updating a JList

Shanna Ripley

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... creates client gui and sends connection to This is my server. It accepts connection from client and creates a ConnectionHandler to handle each connection by each client. This class maintains info about the clients. Adds User objects to a vector to keep track of which clients are online. Stores info about each client, e.g. ip address, port An instance is created to handle each client connection. Details about client are stored in a UsersGroup object. And monitors msgs incoming to server. 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: 10825

Recommended reading

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

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:
subject: help with updating a JList
It's not a secret anymore!