1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| public class FormPrincipale extends JFrame
implements ActionListener, KeyListener
{
//Timer qui fait descendre la pièce
private Timer monTimer = null;
private Piece carre1;
public FormPrincipale(String p_title)
{
super(p_title);
construire();
}
private void construire()
{
// Ajout du composant menu
//La Barre de menu est gérée dans BarreMenu.java
setJMenuBar(new BarreMenu());
JPanel contentPanel=new JPanel(new GridLayout(1,2));
JPanel jeuPanel=new JPanel(null);
JPanel suivantPanel=new JPanel(new FlowLayout());
JPanel scorePanel=new JPanel(new FlowLayout());
jeuPanel.setSize(700,700);
carre1=new Piece();
carre1.setBounds(50,50,50,50);
jeuPanel.add(carre1);
JButton button=new JButton("La pièce suivante");
suivantPanel.add(button);
button.addKeyListener(this);
scorePanel.add(new JButton("Le score"));
contentPanel.add(jeuPanel);
contentPanel.add(suivantPanel);
contentPanel.add(scorePanel);
setContentPane(contentPanel);
contentPanel.addKeyListener(this);
jeuPanel.addKeyListener(this);
suivantPanel.addKeyListener(this);
scorePanel.addKeyListener(this);
creeTimer();
} |
Partager