Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with updating a JList

 
Shanna Ripley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Shanna Ripley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whenever a user object is created it needs a reference to the JList's model,
so it can be added to that model
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic