私の大学のプロジェクトのGUIに取り組んでいます 色で定義された一連の要素を連続して表示する必要があります。 実行時に変更できるので、ListViewを使用しました。 4つ以上の要素はありません。定義された領域を占有するはずですが、ノードをリストのセルの内側に置くと、ノードの周りに境界線(この場合は四角形)が表示され、 ListViewを好みのサイズから外して、両方のスクロールバーを表示します。これは、リストがスクロール可能ではないため、実際には小さいので、バーがほぼすべてをカバーするためです。リストビューのセルが含まれているノードよりも大きくなっています
ここで私は、セルの工場のために書いたコードだ:私は私は知りません
<ListView fx:id="coastBalcony" fixedCellSize="38.0" layoutX="80.0" orientation="HORIZONTAL" prefHeight="40.0" prefWidth="120.0" />
Graphical display of the problem
:
private void initializeBalcony(SimpleListProperty<String> balconyProperty, ListView<String> balconyView) {
balconyView.setBorder(null);
balconyView.setItems(balconyProperty);
balconyView.setCellFactory(row -> new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty)
Platform.runLater(() -> this.setGraphic(null));
else {
this.setMaxSize(27.5, 38);
Rectangle councillor = new Rectangle();
councillor.setWidth(20);
councillor.setHeight(35);
councillor.setFill(Paint.valueOf(item));
Platform.runLater(() -> this.setGraphic(councillor));
}
}
});
}
プラスのListViewのFXML定義は間違って、たぶん私はHBoxを使うべきですが、私はListChangeListenersで問題を抱えていました。