tags:

views:

117

answers:

1

Hi, I've been messing around with awt/swing lately trying to learn how to do applets.

I have written the following short JApplet example code, which on the surface seems to work.

The problems I have occur when I try to exit it:

  1. Pressing ESC does nothing, in fact line 38 is never reached when I run it in the debugger (nor is line 94 - it seems as if the overridden function processKeyEvent(KeyEvent e) is not being called by the applet runner upon keypress at all). However, mouse events do seem to be processed (via the debugger I can see line 99 being reached when i move the mouse).
  2. Trying to close/quit eclipse's applet runner causes it to hang, meaning i have to kill the process. That didn't happen when running another applet through it.
  3. the printed '@' is not at the right size, and I suspect it is not drawing using the fixed width font I set it up to use in line 74.

Any idea what I'm doing wrong?

-Ido.

+1  A: 

It seems that you have not given focus to the applet. When i run it in eclipse, pressing escape does nothing. but when i have clicked inside the grid, pressing escape works just fine. it outputs "not running" in the console. Also closing the applet in eclipse works just fine. Which eclipse version are you running and what Java version?

Savvas Dalkitsis
Ido Yehieli
Yes i am running under windows. Same jdk same eclipse (3.5). It has to be linux. Is this a porblem only in the Eclipse applet view or have you tried it inside a browser window? Maybe it will work there...
Savvas Dalkitsis