我想使用JFoenix滚动窗格实现排行榜。但是我对javafx和Jfoenix完全陌生,并且遇到了一些问题。
认为我有一个ArrayList标签,我想将它们添加到Scrollpane中。我这样做像下面的代码。但是,我在列表上方看到一个蓝色的大顶部栏。我想将其缩小或完全隐藏。这个怎么样或一般来说,如何使用JFoenix实施和排行榜。
代码:
public class LeaderboardController {
@FXML
JFXScrollPane scrollPane;
@FXML
VBox vbox;
@FXML
public void initialize()
{
scrollPane.setMinHeight(1000);
ArrayList<Label> labels = new ArrayList<>();
for (int i =0;i<100;i++)
{
Label label = new Label();
label.setText("Item "+ i);
label.setPrefWidth(300);
label.setPrefHeight(50);
labels.add(label);
}
scrollPane.setContent(vbox);
scrollPane.getTopBar().setVisible(false);
vbox.getChildren().addAll(labels);
}
}
FXML文件:
<JFXScrollPane fx:id="scrollPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: BLACK;" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controllers.LeaderboardController">
<children>
<VBox fx:id="vbox" />
</children>
</JFXScrollPane>