ScrollPane 内にボタンを持つ GridPane があります。必要なボタンの数が ScrollPane の最大サイズを埋めるのに十分でない場合、下の画像のようになります。この空白のスポットを、それを含むペインの背景色に設定する必要があります。
グリッドの背景色をそれを含む背景ペインと同じ色に設定しようとしましたが、ボタンで線に色を付けるだけです。ScrollPane の不透明度を 0 に設定しようとすると、ボタンの不透明度も設定されるため、その後ボタンの不透明度を設定しても何も表示されません。
どうすればこれを行うことができますか??
.
.
.
GridPane grid = new GridPane();
int i=0;
for (int r = 0; r <= new Double(this.buttons.size()/BUTTONS_LINE).intValue(); r++) {
for (int c = 0; c < BUTTONS_LINE; c++) {
if(i < this.buttons.size()){
grid.add(this.buttons.get(i), c, r);
i++;
}else{
break;
}
}
}
ScrollPane spane = new ScrollPane(grid);
grid.getStyleClass().add("grid");
grid.setPrefWidth(0.2*Screen.getMainScreen().getWidth());
spane.getStyleClass().add("scrollPane");
/*spane.setOpacity(0);
grid.setOpacity(1);
for(int j=0; j<grid.getChildren().size();j++){
grid.getChildren().get(j).setOpacity(1);
}*///When I try this, buttons aren't visible neither
spane.setMaxSize(0.2*Screen.getMainScreen().getWidth(), 0.2*Screen.getMainScreen().getHeight() );
.
.
.
そしてCSS:
.scrollPane{
-fx-background-color: #afafaf;
-fx-control-inner-background: #afafaf;
}
.grid{
-fx-background-color:#afafaf;
}