DebugSortedBug.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:skadi 作者:
@Override
public void start(final Stage stage) throws Exception {

    for (int i = 0; i < NUM_ENTRIES; i++) {
        final TestEntry entry = new TestEntry("Entry" + i);
        entryList.add(entry);
        final EntryUpdateService updateService = new EntryUpdateService(entry);
        updateService.start();
    }

    final TableView<TestEntry> table = new TableView<>();
    table.setBorder(Border.EMPTY);
    table.setPadding(Insets.EMPTY);

    final TableColumn<TestEntry, TestEntry.EntryState> onlineColumn = new TableColumn<>("State");
    onlineColumn.setCellValueFactory(p -> p.getValue().onlineProperty());

    final TableColumn<TestEntry, String> nameColumn = new TableColumn<>("Name");
    nameColumn.setCellValueFactory(p -> p.getValue().nameProperty());

    table.getColumns().add(onlineColumn);
    table.getColumns().add(nameColumn);

    table.getSortOrder().add(onlineColumn);  // if commented out the bug disappears
    table.getSortOrder().add(nameColumn);

    final FilteredList<TestEntry> filteredList = entryList.filtered(c -> TestEntry.EntryState.ONLINE == c.getOnline());
    final SortedList<TestEntry> sortedList = new SortedList<>(filteredList);
    sortedList.comparatorProperty().bind(table.comparatorProperty());
    table.setItems(sortedList);

    final Scene scene = new Scene(table, 800, 600);
    stage.setScene(scene);
    stage.show();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号