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
|
TON_PANEL = new JPanel(new GridBagLayout());
int nbLignes = 1 + nbrDonneParUtilisateur ;
//Créer les inserts (insets)
Insets basicInsets = new Insets(2,2,2,2);
// Créer les styles de cellule
CellStyle normalStyle = new CellStyle(1.0, 0.0,
GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL,
basicInsets, 0, 0);
CellStyle endLineStyle = new CellStyle(1.0, 1.0,
GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL, basicInsets,
0, 0);
// Ajouter les composants
XGridBag g = new XGridBag(TON_PANEL);
for(int i = 0; i< nbLignes ; i++){
if( ligneEnCours == (nbLignes-1)){
g.add(TON_LABEL, endLineStyle, i, 0);
g.add(TON_LABEL, endLineStyle, i, 1);
}
else{
g.add(TON_LABEL,normalStyle , i, 0);
g.add(TON_LABEL, normalStyle, i, 1);
}
} |