• Post Reply Bookmark Topic Watch Topic
  • New Topic

Only one instance!  RSS feed

 
Mohamad Obagi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to enable only one instance of chat per user, i mean by that no to let the user open more than window

like in messenger your allowed to open one window.


? any idea guys
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Java in General (intermediate) forum there is at least one good topic about only allowing one instance of an application. If you use the search I'm sure you'll be able to find it.

Inside your application it's a lot easier. Keep a mapping of users to their chat windows. If you want to open a new chat window, check if there already is a chat window for the user. Only if it's not the case you should create the window and of course add the mapping.
Don't forget to remove the mapping if the window is closed though (tip: use a WindowListener).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!