开发者

JavaFX 2: Tables: Update display after having updated data

This is all I need to finish answering my last question.

If you look at my last question, you will see my class, containing four fields, corresponding to the four columns of my table

public static class C开发者_如何学GoontactOptions {

    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();
    }
}

How do I get the GUI to update after I run ContactOptions.one.set?

When I scroll down and back up, it updates. How can I get it to update without scrolling.

I also asked this at https://forums.oracle.com/forums/thread.jspa?threadID=2275725


Maybe you should use one of the methods below:

updateTableColumn(TableColumn col) 

Updates the TableColumn associated with this TableCell.

updateTableRow(TableRow tableRow) 

Updates the TableRow associated with this TableCell.

updateTableView(TableView tv) 

Updates the TableView associated with this TableCell.

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

But I think you had already handled this problem)


For updates to work seamlessly, you should initialize each property and add the xxxProperty method:

private final StringProperty one = new SimpleIntegerProperty();

public StringProperty oneProperty() {
   return one;
}

From my own experience, do not use property names using upperCase letters, like "myOne" or "myONE", as the xxxProperty method won't run.


Which build of JavaFX 2.0 are you using? The reason I ask is that tables changed recently and I want to make sure you are using the latest version.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜