I have this code so that when I select a record in the TableView they automatically load me in their respective fields:
public void gestionarEvento() {
tblViewProductos.getSelectionModel().selectedItemProperty().addListener(
new ChangeListener<Productos>() {
@Override
public void changed(ObservableValue<? extends Productos> observable, Productos valorAnterior, Productos valorSeleccionado) {
if (valorSeleccionado != null) {
txtidProducto.setText(String.valueOf(valorSeleccionado.getIdPro()));
txtdescripcionPro.setText(valorSeleccionado.getDescripcion());
spnMax.setValueFactory(Integer.parseInt(Integer.valueOf(valorSeleccionado.getStockMax())));//ERROR
btnEliminar.setDisable(false);
btnActualizar.setDisable(false);
}
}
});
tblViewPrecio.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Precio>() {
@Override
public void changed(ObservableValue<? extends Precio> observable, Precio valorAnterior, Precio valorSeleccionado) {
if (valorSeleccionado != null) {
txtidPrecio.setText(String.valueOf(valorSeleccionado.getIdPre()));
txtfechaInicio.setValue(Date.valueOf(valorSeleccionado.getFechaInicio()));//ERROR
}
}
});
}
I have tried many things but I still can not upload this data