Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. table.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
  2.     public void valueChanged(ListSelectionEvent event) {
  3.         int selectedRowIndex = tutabla.getSelectedRow();
  4.         int columnCount = tutabla.getColumnCount();
  5.         String[] selectedRowData = new String[columnCount];
  6.            
  7.         // iteras la fila y obtienes los valores de las celdas
  8.         for(int i=0; i<columnCount; i++) {
  9.             selectedRowDate[i] = (String) tutabla.getValueAt(selectedRowIndex, i);
  10.         }
  11.              
  12.         // asignas los valores a tus textfields
  13.         txtNombre.setText(selectedRowData[0]);
  14.         txtApellido.setText(selectedRowData[1]);
  15.         ...
  16.     }
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement