bonjour,
j'aimerai pourvoir réglé la taille d'une colone de string de ma JTable de telle sorte que le string le plus long de la colone soit visible!
est ce que quelqu'un a un petit tuyau?
merci d'avance![]()
bonjour,
j'aimerai pourvoir réglé la taille d'une colone de string de ma JTable de telle sorte que le string le plus long de la colone soit visible!
est ce que quelqu'un a un petit tuyau?
merci d'avance![]()
j'ai trouvé mon bohneur sur un des poste de marlin :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 public void setColumnSize(){ FontMetrics fm = table.getFontMetrics(table.getFont()); for (int i = 0 ; i < table.getColumnCount() ; i++) { int max = 0; for (int j = 0 ; j < table.getRowCount() ; j++) { int taille = fm.stringWidth((String)table.getValueAt(j,i)); if (taille > max) max = taille; } String nom = (String)table.getColumnModel().getColumn(i).getIdentifier(); int taille = fm.stringWidth(nom); if (taille > max) max = taille; table.getColumnModel().getColumn(i).setPreferredWidth(max+10); } }
encore merci marlin![]()
Partager