-1
喂好我有一個問題,我想從數據庫返回的數據,遠遠好加載一個組合框。問題是,當你運行它填補了組合框的方法啓動編譯錯誤。JavaFX的組合框FXML
這是錯誤:了java.lang.RuntimeException:java.lang.reflect.InvocationTargetException
公共類實現FXMLDocumentRegisterController Initializable {
@FXML
private JFXComboBox<String> CmbCountry;
@FXML
private JFXButton BtnBack;
@FXML
void BtnBack_Clicked(ActionEvent event) throws IOException{
Parent parent = FXMLLoader.load(getClass().getResource("FXMLDocumentLogIn.fxml"));
Scene loginScene = new Scene(parent);
Stage stage = (Stage)((Node) event.getSource()).getScene().getWindow();
stage.hide();
stage.setScene(loginScene);
stage.show();
}
@Override
public void initialize(URL url, ResourceBundle rb) {
this.CmbCountry = new JFXComboBox<String>();//aca inicializo el combobox
loadCmb();//aca ejecuto el metodo de carga del combobox
}
private void loadCmb(){//este metodo carga el combobox con los datos devueltos de la base de datos
RepoPais repo = FabricaReposSQL.CrearRepoPais();
Iterable<Pais> p = repo.FindAll(); for (Pais pais : p) {
CmbCountry.getItems().add(pais.Nombre); }
} }
在線路中發生錯誤,其中項目被添加到組合框:CmbCountry.getItems()加(pais.Nombre)。
希望能幫助我非常感謝你:)
[所以]是一個英語專用網站。請張貼在英格爾斯。 [見這裏](http://meta.stackoverflow.com/a/262054/1402846)和[這裏](http://blog.stackoverflow.com/2009/07/non-english-question-policy/),用於詳細信息。謝謝。 – Pang