I want to get a data from a JComboBox to put it in a JTextField from the ID of a database. I perform the following method contained in the UtilsTable class:
public static int getIdx(Object datos[][], JComboBox cmbx){
return Integer.parseInt(datos[cmbx.getSelectedIndex()][0].toString());
}
And I'll call it this way:
BeanUsuario modifUsu = daoUsu.getUsuario(UtilsTable.getIdx(usuLis, cmbxNom));
The BeanUser being a class that contains get and set methods to get the data and daoUsu.getUser contains the query from the DB:
SELECT ID_U, NOMBRE
FROM USUARIOS
AND ID_U = ?