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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| package vue;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class FenetreTest extends JFrame{
private JLabel lblComboBox;
private JComboBox<String> cboListeChoix;
private String[] Liste= {"Cdi1","Cdi2","Cdi3","Cdi4"};
private JButton cmdToutCocher;
private JButton cmdToutDecocher;
private JButton cmdRandom;
private JButton cmdRandom2;
public FenetreTest(String titre,int largeur,int hauteur){
setTitle(titre);
setSize(largeur, hauteur);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridBagLayout());
initComposants();
setVisible(true);
}
public void initComposants() {
GridBagConstraints gbc= new GridBagConstraints();
//*******Label description ComboBox******
gbc.gridx= gbc.gridy =0;
gbc.gridheight=gbc.gridheight=1;
lblComboBox=new JLabel();
lblComboBox.setText("Classe :");
add(lblComboBox,gbc);
//******fin LblComboBox******
//*********ComboBox*******
gbc.gridx=1;
cboListeChoix= new JComboBox<>();
cboListeChoix.setEditable(false);
for (String indexListe : Liste) {
cboListeChoix.addItem(indexListe);
}
add(cboListeChoix,gbc);
//******FinComboBox*******
//******Bouton Tout Cocher****
gbc.gridx=3;
cmdToutCocher=new JButton();
cmdToutCocher.setText("Tout cocher");
add(cmdToutCocher,gbc);
//******Fin tout cocher******
//******Bouton tout decocher******
gbc.gridx=4;
//gbc.gridwidth=GridBagConstraints.REMAINDER;
cmdToutDecocher=new JButton();
cmdToutDecocher.setText("Tout decocher");
add(cmdToutDecocher,gbc);
//******Fin tout decocher******
JPanel panMilieu=new JPanel();
panMilieu.add(new PanResultat());
panMilieu.add(new PanResultat());
panMilieu.setBackground(new Color(200, 100, 40));
gbc.gridy=1;
gbc.gridx=0;
gbc.gridheight=5;
gbc.gridwidth=5;
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill=GridBagConstraints.BOTH;
add(panMilieu, gbc);
gbc.insets=new Insets(10, 0,0, 0);
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill=GridBagConstraints.NONE;
//******Bouton Random****
gbc.gridy=7;
gbc.gridx=3;
gbc.gridheight=1;
gbc.gridwidth=1;
cmdRandom=new JButton();
cmdRandom.setText("Random");
add(cmdRandom,gbc);
//******Fin tout cocher******
//******Bouton Random****
gbc.gridx=4;
gbc.gridwidth=1;
cmdRandom2=new JButton();
cmdRandom2.setText("Group");
add(cmdRandom2,gbc);
//******Fin tout cocher******
}
} |
Partager