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
| import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.JScrollPane;
public class testJTable extends JFrame {
public testJTable() {
super("Fenêtre de test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(640, 480);
setLocationRelativeTo(null);
initialisation();
}
private void initialisation() {
JTable tableau = new JTable();
tableau.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {{"a", "a", null, null},{"a", "a", null, null},{"a", "a", null, null},{"a", "a", null, null}}, new String [] {"Title 1", "Title 2", "Title 3", "Title 4"}));
RealisateurPersonalise realisateur = new RealisateurPersonalise();
tableau.getColumnModel().getColumn(0).setCellRenderer(realisateur);
JScrollPane scroller = new JScrollPane(tableau);
scroller.setBounds(10, 10, 610, 380);
setLayout(null);
add(scroller);
}
public static void main(String args[]) {
testJTable test = new testJTable();
test.setVisible(true);
}
} |
Partager