2011-08-30 74 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方法不會運行。