• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet games played with keys - getting the focus

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I've searched this forum for similar topics and found a few but they didn't help me, so I'm starting a new thread.
I have a small collection of logic games implemented as Java applets. Some of them are controlled with keys and the problem is that the game field is not getting the focus upon loading of the applet in the browser. I tried to overcome the issue by adding a call to requestFocusInWindow() in the init() and start() methods or in different event handlers (for example, in the handler for the New item of the game menu). That helped but not completely: I got consistent behavior in some browser+OS configurations and had no success in others. For example, on the same Windows machine I need to click the game field twice if I load the game with Opera and can play right upon loading if the same game is loaded with Internet Explorer. Could someone suggest me the best technique to get focus to a Canvas placed within the Applet's content panel? Maybe, there are some peculiarities I need to know? Currently, to work around the issue I make the user to select the New item in the game menu in order to start the game - but I don't like this way because most users expect the game to be ready to play once it is loaded and they see the game field. Moreover, this only works for 7 shapes and Snake but still doesn't enable the keys for 15 puzzle if I use Opera under Windows. If it helps, here you can play the games I'm talking about my games site.
Thank you in advance for your advices.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Leo Taurus", please check your private messages for an important administrative matter.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic