TableView中的严重错误:javafx.scene.control.Control loadSkinClass无法加载

时间:2014-01-28 23:04:16

标签: javafx tableview

您好我正在编写基于http://docs.oracle.com/javafx/2/ui_controls/table-view.htm的TableView程序以及类似示例。 我正在使用JavaFX ScenBuilder 1.1生成表格

当程序启动时,我得到一堆不停止的lgos:看起来一遍又一遍地发生同样的错误。

以下是错误转储的一部分

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.IllegalArgumentException: Children: duplicate children added: parent = TableRowSkin[id=null, styleClass=cell indexed-cell table-row-cell]
    at javafx.scene.Parent$1.onProposedChange(Parent.java:307)
    at com.sun.javafx.collections.VetoableObservableList.setAll(VetoableObservableList.java:90)
    at com.sun.javafx.scene.control.skin.TableRowSkin.updateCells(TableRowSkin.java:266)
    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.Scene.layoutDirtyRoots(Scene.java:516)
    at javafx.scene.Scene.doLayoutPass(Scene.java:487)
    at javafx.scene.Scene.preferredSize(Scene.java:1489)
    at javafx.scene.Scene.impl_preferredSize(Scene.java:1516)
    at javafx.stage.Window$9.invalidated(Window.java:716)
    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
    at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
    at javafx.stage.Window.setShowing(Window.java:779)
    at javafx.stage.Window.show(Window.java:794)
    at javafx.stage.Stage.show(Stage.java:229)
    at mytime.MyTime.start(MyTime.java:28)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:216)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    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)

这一直重复,直到我停止程序。 以下是相关代码:

public class ActivityLogEntry {
        private final SimpleStringProperty    activityName = new SimpleStringProperty();
        private final SimpleStringProperty    start_time = new SimpleStringProperty();
        private SimpleStringProperty    duration = new SimpleStringProperty();
        private SimpleStringProperty    comment = new SimpleStringProperty();

    public ActivityLogEntry(String activityName, String start_time, String duration, String comment) {
        this.activityName.set(activityName);
        this.start_time.set(start_time); 
        this.duration.set(duration); 
        this.comment.set(comment); 
    }

    public String getActivityName() {
        return activityName.get();
    }

    public void setActivityName(String ActivityName) {
        this.activityName.set(ActivityName);
    }

    public String getStart_time() {
        return start_time.get();
    }

    public void setStart_time(String start_time) {
        this.start_time.set(start_time);
    }

    public String getDuration() {
        return duration.get();
    }

    public void setDuration(String duration) {
        this.duration.set(duration);
    }

    public String getComment() {
        return comment.get();
    }

    public void setComment(String comment) {
        this.comment.set(comment);
    }
}



public class FXMLDocumentController implements Initializable {

    private Label label;
    @FXML
    private ComboBox SelectActivity;
    @FXML
    private TextArea ActivityCommentEntry;
    @FXML
    private TableView<ActivityLogEntry>   ActivityTable;
    @FXML
    private TableColumn<ActivityLogEntry,String> ActivityDuration;
    @FXML
    private TableColumn<ActivityLogEntry,String> ActivityName;
    @FXML
    private TableColumn<ActivityLogEntry,String> ActivityStartTime;
    @FXML
    private TableColumn<ActivityLogEntry,String> ActivityComment;

    private final ObservableList<ActivityLogEntry> ActivityLog = FXCollections.observableArrayList(
        new ActivityLogEntry("10:00", "Get locale","00:15", "no comment"),
        new ActivityLogEntry("10:15", "Get Parental","00:30", "boring comment"),
        new ActivityLogEntry("10:30", "e-mail","00:20", "no comment") 
    );


        private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");
        label.setText("Hello World!");
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // Gwt Activities and ener into the Table
        loadActivities();

        ActivityDuration.setCellValueFactory(
            new PropertyValueFactory<ActivityLogEntry,String>("duration")
                );
        ActivityName.setCellValueFactory(
            new PropertyValueFactory<ActivityLogEntry,String>("activityName")
                ); 
        ActivityStartTime.setCellValueFactory(
            new PropertyValueFactory<ActivityLogEntry,String>("start_time")
                );   
        ActivityComment.setCellValueFactory(
            new PropertyValueFactory<ActivityLogEntry,String>("comment")
                );

    //    ActivityLog.add(new ActivityLogEntry("10:00", "Get locale","00:15", "no comment"));
    //    ActivityLog.add(new ActivityLogEntry("10:15", "Get Parental","00:30", "boring comment"));
    //    ActivityLog.add(new ActivityLogEntry("10:30", "e-mail","00:20", "no comment")); 

        ActivityTable.setItems(ActivityLog);
        ActivityTable.getColumns().addAll(ActivityStartTime, ActivityName, ActivityDuration,ActivityComment);


    }

    @FXML
    private void SelectActivityAction(ActionEvent event) {
    }

    private void loadActivities() {
        ActivityType.LoadActivities();
    }

}

1 个答案:

答案 0 :(得分:2)

com.sun.javafx.scene.control.skin.TableRowSkin]' for control TableRow[id=null, styleClass=cell indexed-cell table-row-cell] java.lang.IllegalArgumentException: **Children: duplicate children added:** parent = TableRowSkin[id=null, styleClass=cell indexed-cell table-row-cell] at 

通常,当您尝试将已经存在的组件添加到组件中时会发生此错误。

检查您的代码以确保不会发生这种情况(即:添加两次相同的对象)。