javafx.fxml.LoadException它不加载接口javafx

时间:2015-10-20 10:22:04

标签: javafx controller fxml

为什么会出现此错误?其他接口正确加载,但不是这样。

这是组件类

private static final String GUI_NAME = "LoginCliente";

public LoginCliente(TransferData data) {

    super(data, GUI_NAME);
    setTitle("Contratti cliente");
    setResizable(false);

    initModality(Modality.APPLICATION_MODAL);
}

这是控制器类

FrontController fc = CarloanFrontController.getFrontController();
ObservableList<Contratto> contratti;
List<Contratto> listaContratti;
SchermataPrincipale sp;
String nomeUtente = sp.codiceC;

@FXML
private ResourceBundle resources;

@FXML
private URL location;

@FXML
private TableColumn<Contratto, String> colonnaDinizio;

@FXML
private TableColumn<Contratto, String> colonnaAuto;

@FXML
private Node LoginCliente;

@FXML
private TableColumn<Contratto, String> colonnaDFine;

@FXML
private TableView<Contratto> tabellaCliente;

@FXML
private Label nomeCliente;

@FXML
private TableColumn<Contratto, String> colonnaFattura;

@FXML
private Button logOut;

@FXML
void logOut(ActionEvent event) {
    getStage().close();
}

@FXML
void initialize() {
    assert colonnaDinizio != null : "fx:id=\"colonnaDinizio\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert colonnaAuto != null : "fx:id=\"colonnaAuto\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert LoginCliente != null : "fx:id=\"visualizzaContratti\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert colonnaDFine != null : "fx:id=\"colonnaDFine\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert tabellaCliente != null : "fx:id=\"tabellaCliente\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert nomeCliente != null : "fx:id=\"nomeCliente\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert colonnaFattura != null : "fx:id=\"colonnaFattura\" was not injected: check your FXML file 'LoginCliente.fxml'.";
    assert logOut != null : "fx:id=\"logOut\" was not injected: check your FXML file 'LoginCliente.fxml'.";

}


@Override
public void initialize(URL url, ResourceBundle resource) {

    recuperaContratti(nomeUtente);
    tabellaCliente.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    contratti = FXCollections.observableArrayList(listaContratti);
    colonnaAuto.setCellValueFactory(new PropertyValueFactory<Contratto, String>("nomeAuto"));
    colonnaDinizio.setCellValueFactory(new PropertyValueFactory<Contratto, String>("inizioNoleggio"));
    colonnaDFine.setCellValueFactory(new PropertyValueFactory<Contratto, String>("limiteNoleggio"));
    colonnaFattura.setCellValueFactory(new PropertyValueFactory<Contratto, String>("numContratto"));

    tabellaCliente.setItems(contratti);  
}


public void recuperaContratti(String codice) {

    List<Contratto> listaTemp = (List<Contratto>) fc.processRequest("VisualizzaContratti", null);
    for(Contratto c : listaTemp) {

        if(codice.equals(c.getCodiceCliente())) {
            listaContratti.add(c);
        }   
    }
}

public SelectStage getStage(){
    return (SelectStage) LoginCliente.getScene().getWindow();
}

这是代码错误

javafx.fxml.LoadException: /C:/Users/Administrator/Desktop/Universit%c3%a0/workspace/Carloan/bin/presentation/boundary/component/LoginCliente.fxml:9

这是fxml文件的第9行

<Pane id="LoginCliente" fx:id="LoginCliente" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="590.0" prefWidth="778.0" style="-fx-background-color: #BDB7;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="presentation.boundary.controller.LoginClienteController">

                                                                                                                                                                                                                                              

这是加载接口的类

private static final String EXTENSION = ".fxml";

public Region root;
public Object value;
public double width;
public double height;
public Scene scene;


public SelectStage(TransferData data, String scheme) {
    this(data, scheme,false);
} 

public SelectStage(TransferData data, String scheme, boolean fullscreen) {

    Class<?> mainClass = getClass();

    scheme =  scheme + EXTENSION;

    FXMLLoader loader = new FXMLLoader(mainClass.getResource(scheme));

    try {
        root = (Region) loader.load();
        Schermata schermata = loader.getController();
        schermata.inizializzaDati(data);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    width = root.getPrefWidth();
    height = root.getPrefHeight();

    if(fullscreen) {
        width = Screen.getPrimary().getBounds().getWidth();
        height = Screen.getPrimary().getBounds().getHeight();
    }

    scene = new Scene(root, width, height);

    this.setMinWidth(width);
    this.setMinHeight(height);

    setScene(scene);

}

public void setResult(Object obj) {
    value = obj;
}

@Override
public Object showWidow(TransferData data) {
    showAndWait();
    return value;
}

0 个答案:

没有答案