カスタム ListCellFactory を持つ ListView があります。CustomListCell の実装では、setGraphic を使用してリスト アイテムのグラフィックを GridPane に設定しますが、GridPane で ListView の幅全体を埋めることができません。以下は私のコードの短いバージョンです:
class MyListCell extends ListCell<MyObject>
{
private final GridPane _myComponent;
public MyListCell()
{
...
setContentDisplay(ContentDisplay.GRAPHIC_ONLY); // does not help
//this.setPrefWidth(0); // does not help
myComponent.prefWidthProperty().bind(this.widthProperty()); // does not help
}
...
@Override
protected void updateItem(MyObject item, boolean empty)
{
...
setGraphic(_myComponent);
...
}
}
別の投稿からの prefWidth 境界があっても、私の GridPane は大きくなりません! 使用するレイアウト制約の組み合わせに関係なく、次のようになります。
GridPane は、ListCell の全幅に拡張する必要があります (右下隅に削除ボタンを追加したい)。私は頭がおかしくなりました、助けてください!