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
|
public JTable getJTable2()
{
JTable jTable2;
String data2[][] = {
{"", "", "", ""},
{"", "", "", ""},
{"", "", "", ""},
{"", "", "", ""},
{"", "", "", ""},
{"", "", "", ""},
{"", "", "", ""}
};
String fields2[] = {"PIECES DE VIE", "DnAT BRUIT ROSE en dB(A)", "OBJECTIF en dB(A)", "CONFORMITE"};
jTable2 = new JTable(data2, fields2);
centerTable(jTable2);
grasTable(jTable2);
return jTable2;
}
private void centerTable(JTable jtable)
{
DefaultTableCellRenderer custom = new DefaultTableCellRenderer();
custom.setHorizontalAlignment(JLabel.CENTER); // centre les données de ton tableau
for (int i=0 ; i < jtable.getColumnCount() ; i++)
{// centre chaque cellule de ton tableau
jtable.getColumnModel().getColumn(i).setCellRenderer(custom);
}
}
// CODE POUR METTRE EN GRAS LA PREMIERE LIGNE DE MA JTable2
private void grasTable(JTable jtable)
{
DefaultTableCellRenderer custom = new DefaultTableCellRenderer();
custom.setFont(new Font("Helvetica Bold", Font.ITALIC,12));
for(int i=0; i< jtable.getColumnCount(); i++)
{
jtable.get ......... // comment faire ?
}
} |
Partager