themanfalconar
Technical User
Hi there,
I've created a network instant message client/server, similar to MSN. This problem relates to the client only. In simple terms the client is an extension of a JFrame with various text fields and buttons.
I have implemented a notifier facility that pops up a separate undecorated JFrame (with the message) in the system tray area (assuming Windoze) when a message has been received. This works fine, but it is unnecessary when the actual chat window is the active window. Therefore I have used WindowListeners and WindowFocusListeners to detect whether the chat window is active; when it isn't active, then the notifier pops up.
The problem is that when the chat window is not the foreground window, or is iconified, the notifier window also pops up in the background. Unless you have no other windows open, you can't see the notifier. It seems that the notifier works at the same foreground level as the chat window. This is no good, as it defeats the point!!!
Do any of you know how to force a JFrame to become the foreground window, particularly if the code that invokes it comes from a JFrame that is NOT the foreground window?
The basic skeleton of the code is:
Obviously the code is much more complex than illustrated above, but that's basically how it works.
Please help!!!
Cheers,
Dan
I've created a network instant message client/server, similar to MSN. This problem relates to the client only. In simple terms the client is an extension of a JFrame with various text fields and buttons.
I have implemented a notifier facility that pops up a separate undecorated JFrame (with the message) in the system tray area (assuming Windoze) when a message has been received. This works fine, but it is unnecessary when the actual chat window is the active window. Therefore I have used WindowListeners and WindowFocusListeners to detect whether the chat window is active; when it isn't active, then the notifier pops up.
The problem is that when the chat window is not the foreground window, or is iconified, the notifier window also pops up in the background. Unless you have no other windows open, you can't see the notifier. It seems that the notifier works at the same foreground level as the chat window. This is no good, as it defeats the point!!!
Do any of you know how to force a JFrame to become the foreground window, particularly if the code that invokes it comes from a JFrame that is NOT the foreground window?
The basic skeleton of the code is:
Code:
public class ChatWindow extends JFrame
.
.
.
// Thread that is continually listening for messages
if(messageDetected)
{
// NotifierWindow is simply a JFrame that is undecorated
NotifierWindow notify = new NotifierWindow(message);
}
else
{
// keep waiting for messages
}
// end of thread loop
.
.
.
Obviously the code is much more complex than illustrated above, but that's basically how it works.
Please help!!!
Cheers,
Dan