2 pièce(s) jointe(s)
[Taille colonne] Autoresize Mode et Scrollbar
Bonjour,
J'essaye de créer un tableau de donnée, dans un JScollBar, qui bloquerai la taille minimal des colonnes mais s'ajusterai avec la fenêtre lorsqu'elle s'agrandit.
Au début, j'avais fixé les colonnes avec :
Code:
1 2 3 4 5 6 7 8 9 10 11
| table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
int sizeCol = 0;
if(numberCol<=12){
sizeCol =(((27*java.awt.Toolkit.getDefaultToolkit().getScreenSize().width)/44)/numberCol); //Oui je sais c'est précis :p
}
else{
sizeCol =(((27*java.awt.Toolkit.getDefaultToolkit().getScreenSize().width)/44)/12);
}
for (int k=0; k<numberCol;k++){
table.getColumnModel().getColumn(k).setPreferredWidth(sizeCol);
} |
Mais du coup, lorsque j'agrandis ma fenêtre ca ne suit pas ... du coup j'ai fait :
Code:
1 2 3 4 5 6 7 8 9 10 11
| table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
int sizeCol = 0;
if(numberCol<=12){
sizeCol =(((27*java.awt.Toolkit.getDefaultToolkit().getScreenSize().width)/44)/numberCol);
}
else{
sizeCol =(((27*java.awt.Toolkit.getDefaultToolkit().getScreenSize().width)/44)/12);
}
for (int k=0; k<numberCol;k++){
table.getColumnModel().getColumn(k).setMinWidth(sizeCol);
} |
Cette fois ca marche, mais je n'ai pas l'ascenseur quand je rétrécis la fenêtre :\ Meme avec :
Code:
1 2
| scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); |
Pièce jointe 182354
Pièce jointe 182353
On observe qu'il y a bien la barre de scroll horizontale (car je la force) mais pas d'ascenseur pour s'y déplacer :( (La barre verticale n'a jamais posé de problème)
Comment faire ?
Merci beaucoup !
Cordialement,
Zénome