滚动时JavaFX TreeTableView行不见了

编程入门 行业动态 更新时间:2024-10-25 22:28:44
本文介绍了滚动时JavaFX TreeTableView行不见了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在尝试JDK 8中的TreeTableView.在启动程序并正常运行后,我注意到一个问题,即在滚动时,行将被清空.我已经尝试了一切,从重置单元格的可见性,更新时的希望,希望它在更新时会重绘,甚至重置列的可见性.这是我编写的一个测试applet,它显示了当您滚动到树形表视图时,行将被遮盖,但是对于表视图,情况并非如此.

I have been experimenting with the TreeTableView in JDK 8. After getting my program up and functioning, I noticed a problem that when I scrolled, rows would be getting blanked out. I have tried everything from resetting the visibility of the cell, when it updates, in hopes that it would redraw when it gets updated, or even resetting the visibility of the column. Here is a test applet I wrote to show that when you scroll for a tree table view, the rows get blanked out, but for a table view, this is not the case.

public class TableViewTest extends Application{ private TreeTableView treeTable = new TreeTableView(); private TableView regularTable = new TableView(); public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { final ObservableList<Person> data = FXCollections.observableArrayList( new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example"), new Person("Jacob", "Smith", "jacob.smith@example"), new Person("Isabella", "Johnson", "isabella.johnson@example"), new Person("Ethan", "Williams", "ethan.williams@example"), new Person("Emma", "Jones", "emma.jones@example"), new Person("Michael", "Brown", "michael.brown@example") ); // REGULAR TABLE ------------------------------------------------------------------------- Scene tableScene = new Scene(new Group()); Stage tableStage = new Stage(); tableStage.setTitle("Table View Sample"); tableStage.setWidth(300); tableStage.setHeight(500); tableStage.show(); regularTable.getItems().addAll(data); regularTable.setEditable(true); TableColumn regularFirstNameCol = new TableColumn("First Name"); TableColumn regularLastNameCol = new TableColumn("Last Name"); TableColumn regularEmailCol = new TableColumn("Email"); regularFirstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName")); regularLastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName")); regularEmailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email")); regularTable.getColumns().addAll(regularFirstNameCol, regularLastNameCol, regularEmailCol); final VBox vbox1 = new VBox(); vbox1.setSpacing(5); vbox1.setPadding(new Insets(10, 0, 0, 10)); vbox1.getChildren().addAll(regularTable); ((Group) tableScene.getRoot()).getChildren().addAll(vbox1); tableStage.setScene(tableScene); // TREE TABLE ---------------------------------------------------------------------------------------------------------------------- Scene scene = new Scene(new Group()); stage.setTitle("Tree Table Sample"); stage.setWidth(300); stage.setHeight(500); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); treeTable.setEditable(true); TreeTableColumn firstNameCol = new TreeTableColumn("First Name"); TreeTableColumn lastNameCol = new TreeTableColumn("Last Name"); TreeTableColumn emailCol = new TreeTableColumn("Email"); treeTable.getColumns().addAll(firstNameCol, lastNameCol, emailCol); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.setPadding(new Insets(10, 0, 0, 10)); vbox.getChildren().addAll(label, treeTable); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); firstNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("firstName")); lastNameCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("lastName")); emailCol.setCellValueFactory(new TreeItemPropertyValueFactory<Person,String>("email")); TreeItem<Person> root = new TreeItem<Person>(new Person("TEST", "TEST", "TEST")); treeTable.setRoot(root); treeTable.setShowRoot(true); root.setExpanded(true); for (Person person : data){ TreeItem<Person> p = new TreeItem<Person>(person); root.getChildren().add(p); } stage.show(); }

有人知道这个问题的解决方案吗,或者这是TreeTableView的已知错误吗?

Does anybody know a fix / solution for this, or is this a known bug with the TreeTableView ?

我只是使用此示例进行了尝试

I just tried this using this example

wikis.oracle/display/OpenJDK/TreeTableView+ API +示例

我仍然遇到相同的问题:行丢失/被白掉.

and I still get the same issue of rows missing / being whited out.

推荐答案

感谢@Alexander Kirov提供的解决方案.升级到104版可以解决此问题.

Thanks to @Alexander Kirov for the solution. Upgrading to build 104 solved this issue.

更多推荐

滚动时JavaFX TreeTableView行不见了

本文发布于:2023-11-16 18:52:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606913.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不见了   JavaFX   TreeTableView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!