Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (690)
Games in Android Showcase (200)
games submitted by our members
Games in WIP (764)
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  
  Check for applet keyboard focus?  (Read 1888 times)
0 Members and 1 Guest are viewing this topic.
Offline gbeebe

Senior Devvie


Medals: 5
Projects: 1



« Posted 2011-12-29 01:23:11 »

Is there a way for an applet to determine if it's got the keyboard focus or not?  I would like to display a "game paused, click to resume" message to the user when it looses focus.  I've tried to implement FocusListener, but focusGained() and focusLost() don't seem to do anything.  Anyone know of a way to check for focus in an applet?
Offline ra4king

JGO Kernel


Medals: 462
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2011-12-29 01:47:23 »

java.awt.Component has a hasFocus() method which returns true if the component has the keyboard focus. Applet inherits from Component so you can use that method in your Applet.

EDIT: However be careful if you have another component overlaying the applet, then you will have to call that Component's hasFocus() method.

Offline gbeebe

Senior Devvie


Medals: 5
Projects: 1



« Reply #2 - Posted 2011-12-29 02:27:32 »

Sweet, if(this.hasFocus())  works perfectly for what I need.  You're all right.  I don't care what everyone else says about you.   Wink
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 462
Projects: 3
Exp: 5 years


I'm the King!


« Reply #3 - Posted 2011-12-29 04:30:38 »

O_o what do people say about me?!

Offline Riven
Administrator

« JGO Overlord »


Medals: 1239
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2012-01-01 14:59:26 »

O_o what do people say about me?!
I think he refers to my comment on your awkwardness rating Wink

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline ra4king

JGO Kernel


Medals: 462
Projects: 3
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2012-01-01 15:44:34 »

Riven, you're making me look bad Cry

Offline Riven
Administrator

« JGO Overlord »


Medals: 1239
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2012-01-01 16:00:34 »

Riven, you're making me look bad Cry
Oh come on. You were the one pleading for a medal. You gotta expect some counter force.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline ra4king

JGO Kernel


Medals: 462
Projects: 3
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2012-01-01 16:15:03 »

Grin

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
Wave Propagation (152 views)
2016-09-20 13:29:55

steveyg90 (269 views)
2016-09-15 20:41:23

steveyg90 (267 views)
2016-09-15 20:13:52

steveyg90 (304 views)
2016-09-14 14:44:42

steveyg90 (331 views)
2016-09-14 14:42:13

theagentd (365 views)
2016-09-12 16:57:14

theagentd (320 views)
2016-09-12 14:18:31

theagentd (252 views)
2016-09-12 14:14:46

Nihilhis (718 views)
2016-09-01 13:36:54

roseslayer (1287 views)
2016-08-06 11:43:29
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21
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!