JAVA TableView错误严重:javafx.scene.control.Control loadSkinClass无法加载皮肤' StringProperty

时间:2015-04-06 17:40:42

标签: java skin

我有这段代码

@FXML
void search_all(ActionEvent event) throws SQLException {
    Connection conn = null;
    PreparedStatement stmt = null;
    Properties connectionProps = new Properties();

    connectionProps.put("user", "root");
    connectionProps.put("password", "916626");


    String connectionString = "jdbc:mysql://localhost:3306/DBS_projekt";
    list_search = FXCollections.observableArrayList();

    try {
        conn = DriverManager.getConnection(connectionString, connectionProps);
        stmt = conn.prepareStatement("SELECT * FROM bycikel");
        ResultSet rs = stmt.executeQuery();
        // ---- ADD COLUMNS ---
        for(int i=0 ; i<rs.getMetaData().getColumnCount(); i++){
            final int j = i;
            TableColumn mycolumn = new TableColumn(rs.getMetaData().getColumnName(i+1));
            mycolumn.setCellValueFactory(new Callback<CellDataFeatures<ObservableList, String>, ObservableValue<String>>()
            {
                public ObservableValue<String> call (CellDataFeatures < ObservableList, String > param){
                return new SimpleStringProperty(param.getValue().get(j).toString());
            }
            });
            tableview1.getColumns().addAll(mycolumn);
        }

        while(rs.next()){
            ObservableList<String> riadok = FXCollections.observableArrayList();
            for(int i=1 ; i<rs.getMetaData().getColumnCount(); i++){
                riadok.add(rs.getString(i));
            }
            list_search.add(riadok);
        }
        tableview1.setItems(list_search);

    }catch (SQLException e) {
        e.printStackTrace();
    } finally {

        stmt.close();

    }
}

错误是:

SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: TableRow[id=null, styleClass=cell indexed-cell table-row-cell], name: skinClassName, value: com.sun.javafx.scene.control.skin.TableRowSkin]' for control TableRow[id=null, styleClass=cell indexed-cell table-row-cell]

java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:208)
at sample.Controller$1.call(Controller.java:383)
at sample.Controller$1.call(Controller.java:381)
at javafx.scene.control.TableColumn.getCellObservableValue(TableColumn.java:1209)
at javafx.scene.control.TableColumn.getCellObservableValue(TableColumn.java:1179)
at javafx.scene.control.TableCell.updateItem(TableCell.java:543)
at javafx.scene.control.TableCell.indexChanged(TableCell.java:105)
at javafx.scene.control.TableCell$1.invalidated(TableCell.java:93)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:195)
at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:161)
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:130)
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:163)
at javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:112)
at com.sun.javafx.scene.control.skin.TableRowSkin.updateCells(TableRowSkin.java:251)
at com.sun.javafx.scene.control.skin.TableRowSkin.<init>(TableRowSkin.java:88)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at javafx.scene.control.Control.loadSkinClass(Control.java:1044)
at javafx.scene.control.Control.access$500(Control.java:70)
at javafx.scene.control.Control$12.invalidated(Control.java:972)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:127)
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:161)
at com.sun.javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:71)
at javafx.scene.control.Control$12.set(Control.java:964)
at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:59)
at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:31)
at com.sun.javafx.css.StyleableProperty.set(StyleableProperty.java:70)
at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:900)
at javafx.scene.Node.impl_processCSS(Node.java:7419)
at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
at javafx.scene.control.Control.impl_processCSS(Control.java:1154)
at com.sun.javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1598)
at com.sun.javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1500)
at com.sun.javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1523)
at com.sun.javafx.scene.control.skin.VirtualFlow$3.call(VirtualFlow.java:478)
at com.sun.javafx.scene.control.skin.VirtualFlow$3.call(VirtualFlow.java:476)
at com.sun.javafx.scene.control.skin.PositionMapper.computeViewportOffset(PositionMapper.java:143)
at com.sun.javafx.scene.control.skin.VirtualFlow.layoutChildren(VirtualFlow.java:1001)
at javafx.scene.Parent.layout(Parent.java:1018)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Scene.layoutDirtyRoots(Scene.java:524)
at javafx.scene.Scene.doLayoutPass(Scene.java:495)
at javafx.scene.Scene.access$3900(Scene.java:173)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2205)
at com.sun.javafx.tk.Toolkit$5.run(Toolkit.java:363)
at com.sun.javafx.tk.Toolkit$5.run(Toolkit.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:361)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:384)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:463)
at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:332)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:17)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:67)
at java.lang.Thread.run(Thread.java:744)

你可以帮我解决这个错误吗? 我无法理解这一部分:

at sample.Controller$1.call(Controller.java:383) ...........is at line .....
public ObservableValue<String> call (CellDataFeatures < ObservableList, String > param){......

0 个答案:

没有答案