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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| public class fenetre extends JFrame {
private JToggleButton b1=new JToggleButton("-");
private JToggleButton b2=new JToggleButton("1");
private JToggleButton b3=new JToggleButton("2");
private JToggleButton b4=new JToggleButton("3");
private JToggleButton b5=new JToggleButton("4");
private JToggleButton b6=new JToggleButton("5");
private JToggleButton b7=new JToggleButton("6");
private JToggleButton b8=new JToggleButton("7");
private JToggleButton b9=new JToggleButton("8");
private JToggleButton b10=new JToggleButton("9");
private ButtonGroup bg=new ButtonGroup();
private Panneau p;
public fenetre(){
this.setTitle("Sudoku");
this.setSize(600,310);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
p=new Panneau();
bg.add(b1);
bg.add(b2);
bg.add(b3);
bg.add(b4);
bg.add(b5);
bg.add(b6);
bg.add(b7);
bg.add(b8);
bg.add(b9);
bg.add(b10);
GridBagLayout layout=new GridBagLayout();
this.setLayout(layout);
GridBagConstraints c=new GridBagConstraints();
c.fill=GridBagConstraints.BOTH; //POUR REMPLIR TOUT L ESPACE DE LA CASE
c.weightx=100; //POIDS A 100
c.weighty=100; //POIDS A 100
///////////////GRILLE//////////////////////
c.gridx=0; //COIN SUP GAUCHE
c.gridy=0; //COIN SUP GAUCHE
c.gridwidth=3; //S ETEND SUR 3 COLONNES
c.gridheight=10; //S ETEND SUR 10 LIGNES
this.add(p,c); //ON AJOUTE
////////////BOUTONS//////////////////////
//c.anchor=GridBagConstraints.EAST;
c.gridwidth=1; //S ETEND SUR 1 COLONNES
c.gridheight=1; //S ETEND SUR 1 LIGNES
c.gridx=3;
c.gridy=0;
this.add(b1,c);
c.gridx=3;
c.gridy=1;
this.add(b2,c);
c.gridx=3;
c.gridy=2;
this.add(b3,c);
c.gridx=3;
c.gridy=3;
this.add(b4,c);
c.gridx=3;
c.gridy=4;
this.add(b5,c);
c.gridx=3;
c.gridy=5;
this.add(b6,c);
c.gridx=3;
c.gridy=6;
this.add(b7,c);
c.gridx=3;
c.gridy=7;
this.add(b8,c);
c.gridx=3;
c.gridy=8;
this.add(b9,c);
c.gridx=3;
c.gridy=9;
this.add(b10,c);
this.setVisible(true);
}
} |
Partager