Fenetre 2 en cours mais bug, keylister en cours fonctionnel mais non connecté au boundary
parent
eea9162ef4
commit
21744392ca
@ -0,0 +1,85 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package gui;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
* @author nicolas
|
||||
*
|
||||
*/
|
||||
public class JeuSalle extends JFrame implements KeyListener,ActionListener{
|
||||
|
||||
public JeuSalle() {
|
||||
setTitle("Labyrinthe");
|
||||
setSize(1200,600);
|
||||
setLocationRelativeTo(null);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
//setContentPane(ecrire("test"));
|
||||
//JScrollPane test = new JScrollPane();
|
||||
//setContentPane(test);
|
||||
this.setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
public JPanel ecrire(String str) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout());
|
||||
JLabel label = new JLabel(str);
|
||||
panel.add(label);
|
||||
this.setFocusable(true);
|
||||
this.setContentPane(panel);
|
||||
this.addKeyListener(this);
|
||||
this.requestFocus();
|
||||
|
||||
return panel;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
|
||||
*/
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
System.out.println("keyPressed");
|
||||
int code=e.getKeyCode();
|
||||
String key =e.getKeyText(code);
|
||||
System.out.println(key);
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
|
||||
*/
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
|
||||
*/
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue