black_fire 11 de nov. de 2003
kra tirei de um programa meu…
// Código Manual
jTblDadosBusca . setSelectionMode & #40 ; ListSelectionModel . SINGLE_SELECTION & #41 ;;
ListSelectionModel rowTbl = jTblDadosBusca . getSelectionModel & #40 ; & #41 ;;
rowTbl . addListSelectionListener & #40 ; new ListSelectionListener & #40 ; & #41 ; & #123 ;
public void valueChanged & #40 ; ListSelectionEvent evt & #41 ; & #123 ;
rowTblvalueChange & #40 ; evt & #41 ;;
& #125 ;
& #125 ; & #41 ;;
InitTableModel inittablemodel = new InitTableModel & #40 ; headerTable & #41 ;;
jTblDadosBusca . setModel & #40 ; inittablemodel & #41 ;;
//**********
Esse aki é o método que eu disparo no evento
private void rowTblvalueChange(ListSelectionEvent evt) {
int selectedRow;
String montaArquivo;
if (evt.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)evt.getSource();
if (! lsm.isSelectionEmpty()) {
selectedRow = lsm.getMinSelectionIndex();
montaArquivo = (String) jTblDadosBusca.getValueAt(selectedRow, 0);
jTxtFldViewFile.setText("Monitor_"+montaArquivo.substring(2,montaArquivo.length())+".vox");
}
}
Se tiver alguma dúvida posta ae, legal vc dar uma olhada neste link tbm. Lá que eu tirei algumas dicas…
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
http://java.sun.com/docs/books/tutorial/uiswing/events/listselectionlistener.html
Um abraço kra,