Ok here is how it works. I have 2 components, one for the Menus, one for the GameWorld. When you click play, I remove the Menus component and add the GameWorld component. The KeyListener and MouseListener objects are, however, added directly onto the JApplet, not on either component.
Just tried it. Fun! Good sf/x too. I liked discovering what the different objects do. No bugs or problems to report, that I came across. Nicely done!
So, this is a copy of a game on a hand-held? Copying is a good way to learn. I hope your plans include ambitions for designing and writing your own, too.
gouessej, is there something wrong with the listeners in Java?
Putting the Key and MouseListeners on:
-the component that draws the game does not work,
-the GlassPane does not work,
-the RootPane does not work,
-(out of desperation) the JLayeredPane does not work
Only the content pane works for me and the majority of people playing this game.
Is there an inconsistency with different version of Java and/or the operating system they’re installed on?
I did some testing the other day with a very basic applet and was able to get it (using KeyListener) working on my system within Safari. I also tried downloading your source code and modifying it in a few different ways but no luck. I managed to get JDoodleJump to run fine on my system when launched directly from my IDE but it still did not work when running it from Safari (the keys still didn’t work).
I think the problem has something to do with slight differences across OS/browser/JRE combinations in how focus is handled.
to allow keyboard input into buggy java version on Mac. (64bit using Chrome) with my own applets I had to click in the address bar then click back on the applet
Agh was that in the public source code? That must have been the wrong version then since in the current game on my website, both listeners are added to the content pane.
And I really don’t see a difference between Applet and JApplet other than that JApplet supports Swing.
What is the advantage of using Applet?