|
|
@ -32,13 +32,12 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|
|
|
setLocationRelativeTo(null);
|
|
|
|
setLocationRelativeTo(null);
|
|
|
|
setResizable(false);
|
|
|
|
setResizable(false);
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
//setContentPane(ecrire("test"));
|
|
|
|
|
|
|
|
//JScrollPane test = new JScrollPane();
|
|
|
|
|
|
|
|
//setContentPane(test);
|
|
|
|
|
|
|
|
this.setVisible(true);
|
|
|
|
this.setVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Méthode permettant d'écrire du texte dans la fenetre de jeu*/
|
|
|
|
public JPanel ecrire(String str) {
|
|
|
|
public JPanel ecrire(String str) {
|
|
|
|
JPanel panel = new JPanel();
|
|
|
|
JPanel panel = new JPanel();
|
|
|
|
panel.setLayout(new FlowLayout());
|
|
|
|
panel.setLayout(new FlowLayout());
|
|
|
@ -48,7 +47,6 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|
|
|
this.setContentPane(panel);
|
|
|
|
this.setContentPane(panel);
|
|
|
|
this.addKeyListener(this);
|
|
|
|
this.addKeyListener(this);
|
|
|
|
this.requestFocus();
|
|
|
|
this.requestFocus();
|
|
|
|
//this.menu = new Menu();
|
|
|
|
|
|
|
|
this.setVisible(true);
|
|
|
|
this.setVisible(true);
|
|
|
|
return panel;
|
|
|
|
return panel;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57,13 +55,7 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void keyPressed(KeyEvent e) {
|
|
|
|
public void keyPressed(KeyEvent e) {
|
|
|
|
//System.out.println("keyPressed");
|
|
|
|
|
|
|
|
int codeint =e.getKeyCode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//int codeint=Character.getNumericValue(e.getKeyText(code));
|
|
|
|
|
|
|
|
//System.out.println(codeint);
|
|
|
|
|
|
|
|
//String key =e.getKeyText(code);
|
|
|
|
|
|
|
|
//System.out.println(key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,13 +70,13 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
|
|
|
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
|
|
|
|
|
|
|
Entrer du clavier
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void keyTyped(KeyEvent e) {
|
|
|
|
public void keyTyped(KeyEvent e) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
nb = e.getKeyChar();
|
|
|
|
nb = e.getKeyChar();
|
|
|
|
System.out.println(nb);
|
|
|
|
System.out.println(nb);
|
|
|
|
//System.out.println(nb);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
|
|
/* (non-Javadoc)
|
|
|
@ -97,10 +89,12 @@ public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Méthode qui récupère les entrés de type int du clavier*/
|
|
|
|
public int toucheint() {
|
|
|
|
public int toucheint() {
|
|
|
|
System.out.println("sortie"+nb);
|
|
|
|
System.out.println("sortie"+nb);
|
|
|
|
return nb;
|
|
|
|
return nb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Méthode que permet de cacher un texte affiché dans la fenetre*/
|
|
|
|
public void cacher(JPanel panel) {
|
|
|
|
public void cacher(JPanel panel) {
|
|
|
|
panel.setVisible(false);
|
|
|
|
panel.setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|