Checking if window has keyboard focus again


I'm designing an application which will at one stage have it's keyboard focus taken away and redirected to another application. The application in question is Google-Chrome. At this stage my program should pause, or halt it's operations entirely until keyboard focus has been returned.

Some extra information:

  • My application is being written in Java
  • The application that is granted Keyboard focus is Google-Chrome

What I need

A way to test if a JFrame has keyboard focus maybe like:


or something to that effect.


You should be able to use a WindowListener and listen for the windowActivated() event. You would also probably need to listen for windowDeactivated() to stop your current processing.

Make any other pop-up a modal dialog and it becomes a very simple question. The focus will return to the parent window the code line after the line which calls dialog.setVisible(true).

See also The Use of Multiple JFrames, Good/Bad Practice?

Need Your Help

Pointer-to-private-member-function array

c++ function-pointers

I am trying to make an array of pointer to private member functions. The array itself is private, so I don't see why it says:

What does !FILTERs mean?

java object web-crawler crawler4j

I have recently implemented Crawler4j and I am trying to teach myself the code by breaking it down line by line. I am having trouble understanding what the !FILTERS object on the line of code below

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.