中心要素としてaBorderPane
があります。ScrollPane
画面いっぱいに自動的にサイズ変更されます。の内部にScrollPane
は、HBox
コンテンツはありませんが、ドラッグ アンド ドロップ ターゲットの があります。したがって、その親を埋める必要がありScrollPane
ます。
これを行うための好ましい方法は何ですか?
私がこれまでに試したことはScrollPane.resize(...)
、サイズを変更する方法をオーバーライドするHBox
ことですが、かなり複雑で非正統的なようです。
編集:これに便利なコードを追加するには、これが問題を回避する方法ですが、これを行うにはもっと良い方法が必要だと思います:
@Override
public void resize(double width, double height) {
super.resize(width, height);
double scrollBarHeight = 2;
double scrollBarWidth = 2;
for (final Node node : lookupAll(".scroll-bar")) {
if (node instanceof ScrollBar) {
ScrollBar sb = (ScrollBar) node;
if (sb.getOrientation() == Orientation.HORIZONTAL) {
System.out.println("horizontal scrollbar visible = " + sb.isVisible());
System.out.println("width = " + sb.getWidth());
System.out.println("height = " + sb.getHeight());
if(sb.isVisible()){
scrollBarHeight = sb.getHeight();
}
}
if (sb.getOrientation() == Orientation.VERTICAL) {
System.out.println("vertical scrollbar visible = " + sb.isVisible());
System.out.println("width = " + sb.getWidth());
System.out.println("height = " + sb.getHeight());
if(sb.isVisible()){
scrollBarWidth = sb.getWidth();
}
}
}
}
hBox.setPrefSize(width-scrollBarWidth, height-scrollBarHeight);
}
コードの一部はここから抜粋: How to access the Scrollbars of a ScrollPane