Applet : press any key to continue

Hi experts,
I have written an applet that processes some datas, however, at one point, I need the user to press any key (or the enter key) to continue.
This is keyevent is not linked to any object like a button. I tried something like :
this.addKeyListener(new KeyAdapter() {
  public void KeyPressed(KeyEvent e) {
but this produce an extra file$1.class that bothers me (it needs to become a signed jar).
I tried playing with something like : if ( == Event.KEY_PRESS ) with no success.
I'm sure there's a simple way to write in an applet something similar to : while ((ch = (char) !=...).
Thanks experts for your answer !

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why can't you include the file$1.class in your signed jar?

The file$1.class is generated because you're using an anonymous subclass of KeyAdaptor (new KeyAdaptor() {//this is an anonymous class...}).  To get around this you can write your own class like in which you extend KeyAdaptor.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
everflyAuthor Commented:
Thanks savalou. Right, I included the file$1.class in my signed jar but adding "this.addKeyListener(new KeyAdapter() {public void KeyPressed(KeyEvent e) {}});" doesn't wait for me to press any key.
And also, isn't there a easier way to perfom this ?
Mick BarryJava DeveloperCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept savalou's comment as answer

Please leave any comments here within the next seven days.


EE Cleanup Volunteer
How about this:

this.addKeyListener(new KeyAdapter() {
    public void KeyPressed(KeyEvent e) {

//add this bit where you want execution to stop:
boolean continue=false;
while (!continue) {}  //this will loop, until the KeyEvent allows the
                              //execution to continue.

I think that should solve it... The thing that you hadn't taken into account is that KeyListener runs in parallel with your code listening for Events, and if no event is assigned to it, nothing will happen to your main code's execution.  As for the extra class file, I think it's unavoidable but should cause any problems when you create a signed jar
Sorry, read 'should not' in the last sentence
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.