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
| private void build(){
setTitle("Jeu lettres");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width, screenSize.height);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setContentPane(buildContentPane());
}
private JPanel buildContentPane() {
JPanel panel = new JPanel(new GridBagLayout());
panel.setOpaque(false);
panel.setForeground(Color.RED);
JPanel panelAffich = new JPanel(new GridBagLayout());
panelAffich.setForeground(Color.RED);
panelAffich.setOpaque(false);
panelAffich.setVisible(true);
panelAffich.setBackground(Color.BLUE);
JButton bout = new JButton("MY BOUTON");
JPanel panelBoutons = new JPanel(new GridBagLayout());
panelBoutons.add(bout);
panelBoutons.setOpaque(false);
panelBoutons.setBackground(Color.RED);
JPanel panelScore = new JPanel(new GridBagLayout());
panelScore.setBackground(Color.YELLOW);
panelScore.setOpaque(false);
GridBagConstraints c = new GridBagConstraints();
//contraintes pour le panneau d'affichage
//Ajout paneau affichage texte
c.fill = GridBagConstraints.HORIZONTAL;
c.fill = GridBagConstraints.VERTICAL;
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy = 0;
c.gridheight = 1;
c.insets = new Insets(10, 10, 10, 10);
panel.add(panelAffich, c);
//ajout paneau boutons
c.fill = GridBagConstraints.VERTICAL;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridwidth = 3;
c.gridy = 1;
c.gridheight = 4;
c.insets = new Insets(10, 10, 10, 10);
panel.add(panelBoutons, c);
//ajout panneau du score
c.fill = GridBagConstraints.VERTICAL;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 1;
c.gridwidth = 1;
c.gridy = 1;
c.gridheight = 4;
c.insets = new Insets(10, 10, 10, 10);
panel.add(panelScore, c);
return panel;
} |
Partager