• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loss of focus while coming back from the External browser to swing awt application  RSS feed

 
Chirag Borkar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

We have an Swing awt base application which is internally calling the External browser using the JBrowser.dll

When we come back from the any external web application we get some values to process back.

After processing those values we are redrawing the view of the Swing application. However at this point of time we are not able to get the focus on the desired textBox and our key board stops working.

We have noticed that the virtual keypad that we have on the application is working fine. This issue is generated on the random basis.

If somebody have face this issue or know something or have some suggestion then it will be good help.

Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> When we come back from the any external web application...

wild guess:

add a windowListener, and in windowActivated(..) put
textBox.requestFocusInWindow();
 
Chirag Borkar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michale,

Thank you very much for replying.

Actually I have already tried that method, but still its not bringing focus back in my textBox.

I have tried following method also.

public void manuallyRequestFocus()
{
if(textBox.isVisible()){
textBox.setFocusable(true);
boolean getFocus = false;
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
if(!(getFocus = textBox.requestFocusInWindow()))
{
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
if(!(getFocus = textBox.requestFocusInWindow()))
{
System.out.println("*********Failed to get the focus after 2 trials");
}
}
textBox.validate();
}
}
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Use Code Tags next time.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another thing to try: wrap the request in a SwingUtilities.invokeLater
(some times the focus request needs to be delayed)

 
Chirag Borkar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried that also,

Still got the loss of foucs
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!