TorrentViewTable.java 文件源码

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

项目:jfx-torrent 作者:
private void initComponents() {
       torrentViews.addListener((ListChangeListener<TorrentView>) l -> {
           if(l.next()) {
               totalTorrents.set(torrentViews.size());
           }
       });

       final SortedList<TorrentView> sortedTorrents = new SortedList<>(filteredTorrents);
       sortedTorrents.comparatorProperty().bind(torrentTable.comparatorProperty());

       torrentTable.setItems(sortedTorrents);
       torrentTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
       torrentTable.setTableMenuButtonVisible(false);
       torrentTable.setRowFactory(t -> new TorrentViewTableRow<>());

       final String emptyTorrentListMessage = "Go to 'File->Add Torrent...' to add torrents.";
       final Text emptyTorrentListPlaceholder = new Text(emptyTorrentListMessage);
       emptyTorrentListPlaceholder.getStyleClass().add(CssProperties.TORRENT_LIST_EMPTY_TEXT);

       filteredTorrents.predicateProperty().addListener((obs, oldV, newV) -> {
           emptyTorrentListPlaceholder.setText(filteredTorrents.isEmpty() && torrentViews.isEmpty()?
               emptyTorrentListMessage : "No torrents to display.");
       });

       final BorderPane placeholderPane = new BorderPane();
       placeholderPane.getStyleClass().add(CssProperties.PLACEHOLDER_EMPTY);
       placeholderPane.setPadding(new Insets(15, 0, 0, 40));
       placeholderPane.setLeft(emptyTorrentListPlaceholder);
       torrentTable.setPlaceholder(placeholderPane);
       createColumns();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号