JavaFX和Scene Builder,TableView无法显示

时间:2018-11-26 02:09:22

标签: java javafx scenebuilder

我无法在GUI应用程序上显示TableView值。 当我从其他形式退回时,程序抛出异常:

WARNING: Can not retrieve property 'naziv' in PropertyValueFactory: javafx.scene.control.cell.PropertyValueFactory@75409aa8 with provided class type: class classes.Automobil
java.lang.IllegalStateException: Cannot read from unreadable property naziv
    at javafx.base/com.sun.javafx.property.PropertyReference.get(Unknown Source)
    at javafx.controls/javafx.scene.control.cell.PropertyValueFactory.getCellDataReflectively(Unknown Source)
    at javafx.controls/javafx.scene.control.cell.PropertyValueFactory.call(Unknown Source)
    at javafx.controls/javafx.scene.control.cell.PropertyValueFactory.call(Unknown Source)
    at javafx.controls/javafx.scene.control.TableColumn.getCellObservableValue(Unknown Source)
    at javafx.controls/javafx.scene.control.TableColumn.getCellObservableValue(Unknown Source)
    at javafx.controls/javafx.scene.control.TableCell.updateItem(Unknown Source)
    at javafx.controls/javafx.scene.control.TableCell.indexChanged(Unknown Source)
    at javafx.controls/javafx.scene.control.IndexedCell.updateIndex(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.updateCells(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.TableRowSkinBase.<init>(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.TableRowSkin.<init>(Unknown Source)
    at javafx.controls/javafx.scene.control.TableRow.createDefaultSkin(Unknown Source)
    at javafx.controls/javafx.scene.control.Control.doProcessCSS(Unknown Source)
    at javafx.controls/javafx.scene.control.Control.access$000(Unknown Source)
    at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Unknown Source)
    at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Node.processCSS(Unknown Source)
    at javafx.graphics/javafx.scene.Node.applyCss(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.VirtualFlow.setCellIndex(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.VirtualFlow.getCell(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.VirtualFlow.getCellLength(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.VirtualFlow.computeViewportOffset(Unknown Source)
    at javafx.controls/javafx.scene.control.skin.VirtualFlow.layoutChildren(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.layout(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.layout(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.layout(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.layout(Unknown Source)
    at javafx.graphics/javafx.scene.Parent.layout(Unknown Source)
    at javafx.graphics/javafx.scene.Scene.doLayoutPass(Unknown Source)
    at javafx.graphics/javafx.scene.Scene.preferredSize(Unknown Source)
    at javafx.graphics/javafx.scene.Scene$2.preferredSize(Unknown Source)
    at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(Unknown Source)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Unknown Source)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(Unknown Source)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(Unknown Source)
    at javafx.graphics/javafx.stage.Window.setShowing(Unknown Source)
    at javafx.graphics/javafx.stage.Window.show(Unknown Source)
    at javafx.graphics/javafx.stage.Stage.show(Unknown Source)
    at Controllers.DodajVoziloController.dodajVoziloAction(DodajVoziloController.java:179)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javafx.reflect.Trampoline.invoke(Unknown Source)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(Unknown Source)
    at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(Unknown Source)
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
    at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.base/javafx.event.Event.fireEvent(Unknown Source)
    at javafx.graphics/javafx.scene.Node.fireEvent(Unknown Source)
    at javafx.controls/javafx.scene.control.Button.fire(Unknown Source)
    at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
    at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(Unknown Source)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.base/javafx.event.Event.fireEvent(Unknown Source)
    at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Unknown Source)
    at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Unknown Source)
    at javafx.graphics/javafx.scene.Scene.processMouseEvent(Unknown Source)
    at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(Unknown Source)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.View.notifyMouse(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

这是我的初始化方法:

@Override
public void initialize(URL arg0, ResourceBundle arg1) 
{
    Date date=new Date();
    try {
        BufferedReader in;
        in = new BufferedReader(new FileReader("brojPlatformi.txt"));
        brojPlatformiTxt = Integer.parseInt(in.readLine());
        if(prviPut) 
        {
            garage=new Garage(brojPlatformiTxt);
            System.out.println("Prvi put!");
            prviPut=false;
        }
        comboBox.getItems().addAll("Automobil", "Kombi", "Motocikl", "PolicijaMoto", 
                "PolicijaAuto", "SanitetAuto", "SanitetKombi", "VatrogasnoKombi");
        naziv.setCellValueFactory(new PropertyValueFactory<>("naziv"));
        brojSasije.setCellValueFactory(new PropertyValueFactory<>("brojSasije"));
        brojMotora.setCellValueFactory(new PropertyValueFactory<>("brojMotora"));
        registarskiBroj.setCellValueFactory(new PropertyValueFactory<>("registarskiBroj"));
        for(int i=0; i<brojPlatformiTxt; i++)
        {
            comboBoxNum.getItems().add(i+1);
            comboBoxNum1.getItems().add(i+1);
        }


        System.out.println(vvv.isEmpty());
        if(!vvv.isEmpty()) 
        {
            tabelaVozila.setItems(vvv);
            tabelaVozila.refresh();
        }
            //garage.platforme[comboBoxNum.getValue()-1].postaviVoziloNaSlobodnoMjesto(DodajVoziloController.v);


    } 
    catch (NumberFormatException | IOException e) {
        e.printStackTrace();
    }

}

0 个答案:

没有答案