JavaFX:在底部的tableview中有第一行

时间:2016-02-23 18:17:32

标签: java javafx tableview

我在JavaFx中有一个TableView,并且希望行不是从顶部到底部,而是从底部到顶部。 像这样:

这是可能的,还是我应该搜索一个compoletely其他方法来制作它? 谢谢你的帮助!

2 个答案:

答案 0 :(得分:1)

你可以在你的桌子上使用 setRotate(180) 。 然后你必须在你的行上使用 setRotate(180) 。 最后,您必须在标题上使用 setRotate(180)。

示例:

    table.setRowFactory(param -> {  
        final TableRow row = new TableRow();
        row.setRotate(180);
        return row;  
    });
    prestazioniTable.setRotate(180);
    Platform.runLater(()-> {
        for (Node n: prestazioniTable.lookupAll(".column-header > .label")) {
            if (n instanceof Label) {
                n.setRotate(180);
            }
        }
    });
    

答案 1 :(得分:0)

为此,您可能需要查看TableRows及其工厂。

例如以下代码:

    tableview.rowFactoryProperty().set(table->{
        TableRow tr = new TableRow();
        tr.prefHeightProperty().bind(Bindings.when(tr.indexProperty().lessThan(1)).then(100).otherwise(30));
        return tr;
    });

将导致第1行(第0行)的pref高度为100,所有其他行为为30。

在关于表格的一个相当类似的问题的答案中有一些很棒的代码和想法:

Programmatically change the TableView row appearance