• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Applet games played with keys - getting the focus

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Posts: 67403
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Leo Taurus", please check your private messages for an important administrative matter.
Won't you be my neighbor? - Fred Rogers. tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic