2016-05-01 6 views
1

ボタンを使ってjavafxでランダム画像ギャラリーを作っています。画像をクリックする必要があるので、ボタンにimageViewを設定しています。問題は、imageViewがボタンを期待どおりに設定していないことです。ボタンは以下110ボタン上のjavafx画像表示が期待どおりに設定されていない

This is the Before Image note Buttons distance

This is after Image why distance is changed

として県高さと幅を持っているコードは、ボタンのImageViewのを設定するために使用しています。

for(int i=0; i<35; i++){ 
    Button button = list.get(i); 
    ImageView imageview =new ImageView(imageList.get(i)); 
    imageview.setPreserveRatio(true); 
    imageview.setFitHeight(110); 
    imageview.setFitWidth(110); 
    button.setGraphic(imageview); 
} 
+0

私は問題を理解していません。あなたはパディング(画像の周りの灰色の領域)が存在しないようにしますか? – ItachiUchiha

+0

画像ビューを追加する前後のボタンの間隔を確認できます。私は第二のイメージのようにそのスペースを変更したくありません。 –

答えて

1

あなたは空にしButton秒のpaddingを変更する必要があります。

Button button = new Button(null, imageView); 

// quadratic grey background 
button.setBackground(new Background(new BackgroundFill(Color.GREY, CornerRadii.EMPTY, Insets.EMPTY))); 

// no padding 
button.setPadding(Insets.EMPTY); 
関連する問題