I am trying to transfer focus from one instance of IntelliJ to another. Even though the window shows up on top of everything and the cursor starts blinking, the focus is actually in the previous window, and the icon is blinking in the taskbar.
Switching between frames of one process is fine, but switching to another process is the problem.
Windows 7 x64, jdk1.7.0_51
JFrame frame = WindowManager.getInstance().getFrame(project);
//the only reliable way I found to bring it to the top
boolean aot = frame.isAlwaysOnTop();
frame.setAlwaysOnTop(true);
frame.setAlwaysOnTop(aot);
int frameState = frame.getExtendedState();
if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) {
// restore the frame if it is minimized
frame.setExtendedState(frameState ^ Frame.ICONIFIED);
}
frame.toFront();
frame.requestFocus();
//frame.requestFocusInWindow(); same behaviour as requestFocus
I also tried Robot, and creating new temporary Frame as was suggested in other questions with no luck.