Kennywen
asked on
Detect second instance of the same program
How can i detect the second instance of the same GUI program and then when the second window popup it will not overwrite and get focus from the first window?
E.g.
I have a GUI program, when i start the program i want to detect there is exisitng same GUI program is running or not. If yes, then i will make the second GUI program to hide behind the first GUI program and the first GUI program will not lost focus(Because maybe I'm writing something on the first GUI program when i launch the second GUI program)
thanks in advance.
E.g.
I have a GUI program, when i start the program i want to detect there is exisitng same GUI program is running or not. If yes, then i will make the second GUI program to hide behind the first GUI program and the first GUI program will not lost focus(Because maybe I'm writing something on the first GUI program when i launch the second GUI program)
thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
and how can i detect and delete the .lock file when all the instance is exit.
thanks
thanks
ASKER
E.g. When i first time to run the program (A instance) and it create a lock file and then when i run the second instance (B instance) of the same program then the second instance will hide behind the first instance.
But my problem is if i close the first instance then open another instance (C instance) then the C instance will overwrite the B instance rigth? So do i need to create a timer and try to create the lock file?
thanks
But my problem is if i close the first instance then open another instance (C instance) then the C instance will overwrite the B instance rigth? So do i need to create a timer and try to create the lock file?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The given snippet (i.e. the applications I wrote around it) works on any MSWindows, UNIX, LINUX and Solaris.
;JOOP!
;JOOP!
ASKER
how to use the sendToBack method in the JFrame?
thanks
thanks
JFrame inherits the "toBack()" from class java.awt.Window
However, this may lead to "forgetting" about the hidden application.
Maybe iconize ( .setExtendedState(ICONIFIE D); ) and make the title show outstanding.
;JOOP!
However, this may lead to "forgetting" about the hidden application.
Maybe iconize ( .setExtendedState(ICONIFIE
;JOOP!
ASKER
Sorry, can you provide more complete code for me.
Actually i just want to display the frame in first come first serve sequence.
thanks
Actually i just want to display the frame in first come first serve sequence.
thanks
I don't understand "first come first serve"
;JOOP!
;JOOP!
ASKER
>> setExtendedState(ICONIFIED );
the above code will just minimize the frame.
the above code will just minimize the frame.
ASKER
Sorry, i will describe more:
Actually there is only 1 frame in the program but the program can be launch many time. E.g. in console 1 type :java popUp, in console 2 type :java popUp, in console 3 type :java popUp. So this will bring up 3 popUp frame and i want to make the popUp frame in first come first serve sequence (that mean which frame is launch first will on top on the screen). so how can i do it? because currently the order is last come first serve. (that mean the last launch frame will on top)
thanks
Actually there is only 1 frame in the program but the program can be launch many time. E.g. in console 1 type :java popUp, in console 2 type :java popUp, in console 3 type :java popUp. So this will bring up 3 popUp frame and i want to make the popUp frame in first come first serve sequence (that mean which frame is launch first will on top on the screen). so how can i do it? because currently the order is last come first serve. (that mean the last launch frame will on top)
thanks
Yes, read what I said: hidden applications tend to be forgotten,
those with interesting or even changing icons on the task bar will not.
But it's up to you to say .toBack();
;JOOP!
those with interesting or even changing icons on the task bar will not.
But it's up to you to say .toBack();
;JOOP!
The call:
if(Solitarity.solitaire())
{
myFrame.toBack();
}
Will do exactly as you wish: #1 on top, #3 at the bottom.
;JOOP!
if(Solitarity.solitaire())
{
myFrame.toBack();
}
Will do exactly as you wish: #1 on top, #3 at the bottom.
;JOOP!
OK
ASKER
thanks