Prasanna

pageicon Thursday Apr 26, 2007

Swing: The problem with JFrame.toFront

I was trying to make a JFrame active after it was minimized. The code snippet is as follows

JFrame frame = new JFrame(.....);
....
....
if (frame.isVisible() == true)
{
   frame.toFront();
   frame.setState(Frame.NORMAL);
}

The above code works, but fails to make the frame active and one needs to click the frame window again to make it active. There were other alternatives like

frame.requestFocus() and frame.requestFocusInWwindow(), but they didn't produce the desired results I expected. I am not sure about the sequence of APIs which would accomplish the task.

Interestingly, there were lot of discussions about the behavior of JFrame.toFront() , but the question is can we make a minimized JFrame active.
Comments:

Prasanna, i've been facing the same problem where the window i'm trying to pop up remains "inactive" or grey. I've been playing around with the libraries to figure how to get a minimized window to pop up, but so far nothing. The closest point I've reached now is to have a window (JFrame) which is Not on TOP come forward and have its Title Bar in the Start Menu tray blink blue. The window remains inactive though. I've tried using the frame.toFront(); function but that doesn't send the window on top of all windows. It just blinks blue and remains highlited in the tray. How did it work with you?

Posted by Abe on August 02, 2007 at 03:52 AM IST #

For me sometimes, it pops up and remains inactive but for most of the time it blinks blue, I have been trying different sequences of APIs related to this, but no success till now (only the above sequence gives the near best result), I will try to resolve this with experts and once I find the soultion, I will post the code here.

Posted by Prasanna Seshadri on August 02, 2007 at 03:48 PM IST #

If not too late you can use the same technique as in here:
http://forums.sun.com/thread.jspa?threadID=777887&messageID=4427023

Posted by sans17 on August 28, 2008 at 03:53 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed