Tenho o seguinte metodo que chama uma nova janela
private void Editar() {
try {
if (con != null) {
FXMLLoader fxmlloader = new FXMLLoader(getClass().getResource("/layout/sql/cadrelat.fxml"));
// Definindo quem é o controller desse 'fxml':
fxmlloader.setController(new `enter code here`criaRela(topData.getSelectionModel().getSelectedItem(),con,1));
Stage stage = (Stage) btnEdit.getScene().getWindow();
// Carregando o fxml na scene:
stage.setScene(new Scene(fxmlloader.load()));
stage.setMaximized(true);
stage.show();
}
} catch (Exception | Error ex) {
ex.printStackTrace();
new TopException(ex, this.getClass());
}
}
– mas não estou conseguindo carregar o dado do banco, pois aparece que o campo de text field é nulo
@Override
public void initialize(URL url,ResourceBundle rb) {
btnSalvar.setOnAction(e -> OnSalvar());
btnCance.setOnAction(e -> OnCance());
}
public criaRela(TabRela rela, Connection con,int tela) throws Exception {
this.tela = tela;
this.con = con;
if(tela == 0){
//tela = 1;
}else{
this.rela = rela;
try {
this.aces = new TabAcesDao(con).getRegistro(rela.getCodaces().getCodaces());
} catch (Exception | Error ex) {
ex.printStackTrace();
}
System.out.println("Acesso: " + aces + "\n" + aces.getPaiaces());
//carregarCombo();
carregarDados(rela, aces);
}
}
private void carregarDados(TabRela rela, TabAces aces) {
try {
if (con != null) {
System.out.println(""+aces.getPaiaces());
txtPaiAce.setText(aces.getPaiaces().toString());
}