I am receiving the userlist at socket in 10 seconds of interval which is a single string and i'm splitting that string to individual string of username and There is a Homepanel class where userlist is displayed and i want that panel has user name in (Jlabel)as many number as user created by splitting. how can i do that or is thre any other better way please suggest
Quickest way could be to write a public method in the Homepanel class that takes the userlist (or pre-split array of usernames) as a parameter and updates the GUI accordingly. Pass a reference to the HOmepanel into the socket-handling class so it can call the public method.
Best way, avoiding hard-wring the GUI ref into the socket layer, is to use a Listener pattern where the socket layer sends "user list updated" events to registered listeners - just like Swing does everywhere. This is better architecture, but more code - it all depends on how "serious" this application is.