Boa noite amigos.
Estou com um problema que parecia ser simples, mas ja estou ha alguns dias me batendo e nao saio do lugar...
table.getSelectedRow();
sera que algum de voces poderia me ajudar? ai vai o codigo do filtro...
// Implementa o listener do campo.
searchField.setDocument(new AmostechDocument(
AmostechDocument.TYPE_UPPER_ALL));
searchField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
newFilter();
}
public void insertUpdate(DocumentEvent e) {
newFilter();
}
public void removeUpdate(DocumentEvent e) {
newFilter();
}
});
O codigo do filter...
/**
* Update the row filter regular expression from the expression in the text
* box.
*/
private void newFilter() {
RowFilter<ObjectTableModel<T>, Object> rf = null;
// If current expression doesn't parse, don't update.
try {
rf = RowFilter.regexFilter(searchField.getText());
} catch (java.util.regex.PatternSyntaxException e) {
return;
}
sorter.setRowFilter(rf);
}
E o codigo do listener...
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
int countClicks = e.getClickCount();
if (countClicks == 2) {
// Double clicked somewhere...
if (table.getSelectedRows().length == 1) {
// User double clicked one row only!
int i = table.getSelectedRow();
//Perdemos os indexes... isso eh muito importante!
// Varrer o searchmodel para encontrar o index correto.
table.getValueAt(i, 0);
System.out.println("Code do produto que voce selecionou..."+table.getSelectionModel().getLeadSelectionIndex());
getModelToUpdate().add(((ObjectTableModel<T>)table.getModel()).getValue(i));
System.out.println("Adicionar...");
}
}
}
Alguem saberia como fazer para corrigir isto?