I am trying to use an update method on my jtable that\'s connected to the database and would like to fill in the textfields on the form depending on which row the users clic
You will need to call getValueAt() your table's model to get the values you need. You will also need a listener on the table to listen for selections. So that once a user selects a row you call getValueAt() to get the value for the specific column of data in that row.
private final UrTableModel urTableModel;
private JTable urTable;
...
// 1. Create your table model class that should extends from DefaultTableModel, instantiate it
urTableModel=new UrTableModel();
// 2. creates table
table = TableUtils.createStandardSortableTable(urTableModel);
// 3. customize your table
table.setBackground(Color.WHITE);
table.getTableHeader().setReorderingAllowed(false);
// 4. Add the mouse listner to it
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 1) {
final JTable target = (JTable)e.getSource();
final int row = target.getSelectedRow();
final int column = target.getSelectedColumn();
// Cast to ur Object type
final UrObjctInCell urObjctInCell = (UrObjctInCell)target.getValueAt(row, column);
// TODO WHAT U WANT!
}
}
});
Cheers,