Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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 1161 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
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« 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: 8



« 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.
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


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 Wizard


Medals: 51
Projects: 11
Exp: 12 years


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);

Subscribe to me on YouTube: http://youtube.com/javaprogrammerguy
Offline ra4king

JGO Kernel


Medals: 337
Projects: 2
Exp: 5 years


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 Ninja


Medals: 46
Projects: 4


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  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

pw (37 views)
2014-07-24 01:59:36

Riven (38 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00

Cero (60 views)
2014-07-16 00:42:17

Riven (57 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!