keylistener problem with applet

  • Thread starter biner.sebastien
  • Start date
B

biner.sebastien

Hello,

I am working on a little applet game. The applet reads the keys with
a keylistener.

I develop the Applet on Linux using appletviewer and/or Eclipse
(which uses appletviewer I think). When I start the applet this way, it
does not register the key I press. But if open the applet using Firefox
it works. I also tested the Applet with appletviewer on Windows XP and
Mac OsX10.3 and it works.

Has anybody experienced similar problem? Any hint of a solution? If
useful, I use Xandros linux version 3.

I put the code for the Applet at the end of this email if it may help
you help me.

Thanks for any help.

Sebastien.

*** start of code ***

import javax.swing.* ;
import java.awt.* ;


public class Ai1 extends JApplet {

PControle pcontrole ;
PDessin pdessin ;
PJeux pjeux ;
Container cp ;
boolean focus ;


public Vehicule1 v1 = new Vehicule1() ;

// methode init
public void init() {

// on met le focus sur l'applet et on ecoute le clavier
this.setFocusable(true) ;
this.requestFocus() ;
this.addKeyListener(new ecouteClavier(v1)) ;

// initialisation des panel
pdessin = new PDessin(Utilitaires.niPDessin,Utilitaires.njPDessin,v1)
;
pcontrole = new PControle() ;
pjeux = new PJeux(v1) ;

// ajout de panel a l'applet
cp=getContentPane() ;
cp.setLayout(new BoxLayout(cp,BoxLayout.X_AXIS)) ;
//cp.add(pdessin) ;
cp.add(pjeux) ;
cp.add(pcontrole) ;



} // fin init
} //fin Ai1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top