How do you lose focus?

I want my game to lose focus when the player presses a certain key (escape).
What method can I used on the component to accomplish this? I’ve looked through the API and there appears to be no equivalent to a “loseFocus()” method
Thanks

I guess if there was a way to disable then re-enable it may push the focus out… or (more drastically) hide and show. Some APIs have the blur() method which will remove focus. Not 100% sure the exact answer because I don’t mess with the UI stuff.

Whatever you’re planning, it sounds like a bad idea. The only thing that a window having focus means is that you receive key events. If you don’t want key events, then just ignore them.

Uhhh…java.awt.Robot move mouse outside, then click?
Probably not a good idea ;D

From the thread title I thought that you were some sort of super-programmer who was asking other programmers for how to not focus.

You cannot force an application to lose focus…at least with AWT.

It really depends on what you mean specifically, but you might look into this:

http://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#toBack()

What do you mean by “lose focus”?? ??? If you have gor the mouse grabbed, just “ungrabbit” using Mouse.setGrabbed(false);

That only works when there are other windows open in the JVM, according to the javadocs.

I got that feeling that he meant that he wanted the camera to lose focus, i.e everything becomes blurry.
E.G

I’ve lost focus as to what I am doing.
Wait where am I?