2011-08-30 72 views
2

这就是我需要完成回答my last questionJavaFX 2:表格:更新数据后更新显示

如果你看一下我的最后一个问题,你会看到我的课,包含四个字段,对应于我的表的四列

public static class ContactOptions { 

    private final StringProperty one; 
    private final StringProperty two; 
    private final StringProperty three; 
    private final StringProperty four; 

    ContactOptions(String col1, String col2, String col3, String col4) { 
     this.one = new StringProperty(col1); 
     this.two = new StringProperty(col2); 
     this.three = new StringProperty(col3); 
     this.four = new StringProperty(col4); 
    } 

    public String getOne() { 
     return one.get(); 
    } 

    public String getTwo() { 
     return two.get(); 
    } 

    public String getThree() { 
     return three.get(); 
    } 

    public String getFour() { 
     return four.get(); 
    } 
} 

如何获得GUI来更新我跑ContactOptions.one.set后?

当我向下滚动并备份时,它会更新。我如何在不滚动的情况下更新它。

我也问了这个在https://forums.oracle.com/forums/thread.jspa?threadID=2275725

回答

2

也许你应该使用以下方法之一:

updateTableColumn(TableColumn col) 

更新与此相关的TableCell的TableColumn。

updateTableRow(TableRow tableRow) 

更新与此TableCell关联的TableRow。

updateTableView(TableView tv) 

更新与此TableCell关联的TableView。

(从http://docs.oracle.com/javafx/2.0/api/javafx/scene/control/TableCell.html

但我认为你已经处理了这个问题)

+0

是的,我已经处理了这个项目。但不使用这些方法。看起来就是我所需要的。 – Dorothy

1

您正在使用哪个构建的JavaFX 2.0的?我问的原因是表格最近改变了,我想确保你使用的是最新版本。

2

对于更新无缝地工作,你应该初始化每个属性,并添加xxxProperty方法:

private final StringProperty one = new SimpleIntegerProperty(); 

public StringProperty oneProperty() { 
    return one; 
} 

根据我自己的经验,不要使用使用大写字母的属性名称,如“myOne”或“myONE”,因为xxxProperty方法不会运行。