1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public void creerTable() {
String[] columnsNames = {"Type","Cout (euros/heure)","Temps (mn/unite)","Cout (euros/unite)"};
table = new JTable(new MyTableModel(columnsNames));
//TODO AJOUT DU LISTENER
table.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent arg0) {
System.out.println(""+table.getValueAt(table.getSelectedRow(),1));
System.out.println(""+table.getValueAt(table.getSelectedRow(),2));
System.out.println(""+table.getValueAt(table.getSelectedRow(),3));
coutH.setText(""+table.getValueAt(table.getSelectedRow(),1));
temps.setText(""+table.getValueAt(table.getSelectedRow(),2));
cout.setText(""+table.getValueAt(table.getSelectedRow(),3));
actualiser();
validate();
repaint();
System.out.println("et pourtant, le texte est bien "+coutH.getText());
} |
Partager