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 47 48 49 50
|
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.*;
public class Fenetre extends JFrame implements ActionListener, WindowListener, MouseListener, KeyListener
{
private Button b1,b2,b3,b4;
public Fenetre ()
{
Toolkit k = Toolkit.getDefaultToolkit();
Dimension tailleEcran = k.getScreenSize();
int largeurEcran = tailleEcran.width;
int hauteurEcran = tailleEcran.height;
setTitle("Jeu");
setSize(largeurEcran,hauteurEcran);
setLocation(0,0);
setVisible(true);
addWindowListener(this);
b1=new Button("Jouer");
b1.addActionListener(this);
b1.setSize (200,50);
b1.setLocation(largeurEcran/2-100,100);
getContentPane().add(b1);
b2=new Button("Options");
b2.addActionListener(this);
b2.setSize (200,50);
b2.setLocation(largeurEcran/2-100,200);
getContentPane().add(b2);
b3=new Button("Credits");
b3.addActionListener(this);
b3.setSize (200,50);
b3.setLocation(largeurEcran/2-100,300);
getContentPane().add(b3);
b4=new Button("Quitter");
b4.addActionListener(this);
b4.setSize (200,50);
b4.setLocation(largeurEcran/2-100,400);
getContentPane().add(b4);
}
...
} |
Partager