Alô Galera do PJ.
Preciso dum Help de vocês. Confesso minha pouca pratica no assunto.
O exemplo abaixo mostra como descobrir qual ROW/COLUMN alterada na Jtable. Ou seja: o usuario escolhe uma ROW/COLUMN da Jtable e resolve alterar seu conteudo. Esse conteudo preciso acessar para mandar para o DB.
O código abaixo busquei na Internet.
SelectionListener listener = new SelectionListener(table);
table.getSelectionModel().addListSelectionListener(listener);
table.getColumnModel().getSelectionModel().addListSelectionListener(listener);
public class SelectionListener implements ListSelectionListener {
JTable table;
// It is necessary to keep the table since it is not possible
// to determine the table from the event's source
SelectionListener(JTable table) {
this.table = table;
}
public void valueChanged(ListSelectionEvent e) {
// If cell selection is enabled, both row and column change events are fired
if (e.getSource() == table.getSelectionModel()
&& table.getRowSelectionAllowed()) {
// Column selection changed
int first = e.getFirstIndex();
int last = e.getLastIndex();
} else if (e.getSource() == table.getColumnModel().getSelectionModel()
&& table.getColumnSelectionAllowed() ){
// Row selection changed
int first = e.getFirstIndex();
int last = e.getLastIndex();
}
if (e.getValueIsAdjusting()) {
// The mouse button has not yet been released
}
}
}
Deu pra entender o que estou precisando ???
Algum Help rápido ??
Obrigadooooo.
Ateh.