*
The moose likes Swing / AWT / SWT and the fly likes Activating window from background process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Activating window from background process" Watch "Activating window from background process" New topic
Author

Activating window from background process

Alex Sasha
Greenhorn

Joined: Sep 02, 2011
Posts: 6
Hello,
I have a running java process (the process runs in background) that should popup a dialog when it gets request from outside. The problem is that even if I call setAlwaysOnTop the dialog windows shows on top and even the cursor is in the first edit box of this dialog, but window itself is not really active before I click on it, and I can’t start typing immediately, I have to click on it to activate a process.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
It sounds like your focus is elsewhere. Have the desired component in the popup request focus.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Alex Sasha
Greenhorn

Joined: Sep 02, 2011
Posts: 6
Greg Brannon wrote:It sounds like your focus is elsewhere. Have the desired component in the popup request focus.

Yes, i did that. The problem is not a focus, as i understand the problem is a task switch, java can't switch tasks, and then it's not possible to switch to window of inactive task.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

If I understand that correctly, the problem is that some other application is the active one.

You could try using java.awt.Robot to click in your application dialog after it's made visible.


luck, db
There are no new questions, but there may be new answers.
Alex Sasha
Greenhorn

Joined: Sep 02, 2011
Posts: 6
Darryl Burke wrote:If I understand that correctly, the problem is that some other application is the active one.

You could try using java.awt.Robot to click in your application dialog after it's made visible.


Yes that's right i could try that trick, but i think the only real solution is using JNI and calling SetForegroundWindow from user32.dll
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Activating window from background process