Search code examples
javafxjavafx-2repaint

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

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


Solution

  • 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)