Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Activating window from background process

 
Alex Sasha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like your focus is elsewhere. Have the desired component in the popup request focus.
 
Alex Sasha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5125
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alex Sasha
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic