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 51 52 53 54 55 56 57 58 59
| package shuthebox;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FenetreDeJeu extends JFrame{
private JPanel panneau;
private JButton domino1, domino2, domino3, domino4, domino5, domino6, domino7, domino8, domino9, domino10, domino11, domino12;
private JLabel titre = new JLabel("Shut The Box");
public FenetreDeJeu(){
setTitle("Shut The Box");
setSize(800,700);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
JPanel panneau = new JPanel();
panneau.setBackground(Color.GRAY);
this.setTitle("Shut The Box");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setContentPane(panneau);
this.setLayout(null);
JPanel dominos = new JPanel();
dominos.setLayout(new GridLayout(2, 6));
dominos.add(new JButton("1"));
dominos.add(new JButton("2"));
dominos.add(new JButton("3"));
dominos.add(new JButton("4"));
dominos.add(new JButton("5"));
dominos.add(new JButton("6"));
dominos.add(new JButton("7"));
dominos.add(new JButton("8"));
dominos.add(new JButton("9"));
dominos.add(new JButton("10"));
dominos.add(new JButton("11"));
dominos.add(new JButton("12"));
panneau.add(dominos);
dominos.setBounds(50,50,700,200);
JButton nouvellepartie = new JButton("Nouvelle Partie");
panneau.add(nouvellepartie);
nouvellepartie.setBounds(600,600, 120,50);
Font police = new Font("Tahoma", Font.BOLD, 36);
titre.setFont(police);
titre.setForeground(Color.black);
panneau.add(titre);
titre.setAlignmentX(300);
titre.setAlignmentY(600);
this.setVisible(true);
}
public static void main(String[] args){
new FenetreDeJeu(); //pour tester
}
} |
Partager