Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (307)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How do you lose focus?  (Read 652 times)
0 Members and 1 Guest are viewing this topic.
Offline nhmllr

Senior Member


Medals: 1
Projects: 3


slow and steady...


« Posted 2013-01-02 00:11:16 »

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
Offline LunaticEdit

Senior Member


Medals: 8
Projects: 1



« Reply #1 - Posted 2013-01-02 00:18:51 »

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.

Offline Best Username Ever

Junior Member





« Reply #2 - Posted 2013-01-02 01:20:57 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« Reply #3 - Posted 2013-01-02 02:03:00 »

Uhhh....java.awt.Robot move mouse outside, then click?
Probably not a good idea Grin
Offline Sickan

Senior Member


Medals: 7



« Reply #4 - Posted 2013-01-02 02:25:44 »

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

I'm just here to learn.
Offline ra4king

JGO Kernel


Medals: 292
Projects: 2


I'm the King!


« Reply #5 - Posted 2013-01-02 06:16:48 »

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

Offline KevinWorkman

JGO Knight


Medals: 9
Projects: 9


klaatu barada nikto


« Reply #6 - Posted 2013-01-02 20:12:24 »

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%28%29

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline PeterNicholson

Senior Member


Medals: 3
Projects: 1



« Reply #7 - Posted 2013-01-02 20:45:46 »

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

JGO Kernel


Medals: 292
Projects: 2


I'm the King!


« Reply #8 - Posted 2013-01-02 21:19:45 »

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%28%29
That only works when there are other windows open in the JVM, according to the javadocs.

Offline 5c0jt

Junior Newbie





« Reply #9 - Posted 2013-01-02 21:21:41 »

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

[._.]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline namrog84

JGO Knight


Medals: 23
Projects: 2


Keep programming!


« Reply #10 - Posted 2013-01-02 21:36:36 »

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

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

"Experience is what you get when you did not get what you wanted"
Pages: [1]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
mrbenebob (18 views)
2013-06-19 14:55:23

BrassApparatus (28 views)
2013-06-19 08:52:37

NegativeZero (31 views)
2013-06-19 03:31:52

NegativeZero (33 views)
2013-06-19 03:24:09

Jesse_Attard (37 views)
2013-06-18 22:03:02

HeroesGraveDev (74 views)
2013-06-15 23:35:23

Vermeer (75 views)
2013-06-14 20:08:06

davedes (76 views)
2013-06-14 16:03:55

alaslipknot (68 views)
2013-06-13 07:56:31

Roquen (91 views)
2013-06-12 04:12:32
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!