2014-01-28 19 views
0

您好我正在編寫基於http://docs.oracle.com/javafx/2/ui_controls/table-view.htm和類似示例的TableView程序。 我產生tablesusing的JavaFX 1.1 ScenBuilderTableView中的嚴重錯誤:javafx.scene.control.Control loadSkinClass加載失敗

程序啓動時,我得到了一堆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(); 
    } 

} 

回答

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 

通常,當您嘗試添加一個已經已經存在到組件此錯誤發生。

檢查您的代碼以確保不會發生這種情況(即:添加兩次相同的對象)。

+0

賓果!問題是SceneBuilder已經將列添加到.fxml文件中的表中,所以我不應該有ActivityTable.getColumns()。addAll(ActivityStartTime,ActivityName,ActivityDuration,ActivityComment); – user3246650

相關問題