break;
}
}
}
BorderPane borderPane = new BorderPane();
Carousel<ImageHandle> carousel = new Carousel<>();
carousel.setMinWidth(500);
carousel.setMinHeight(300);
carousel.setMouseTransparent(false);
carousel.setPickOnBounds(true);
carousel.setFocusTraversable(true);
for(Image image : images) {
carousel.itemsProperty().get().add(new ImageHandle(new ImageView(image)));
}
carousel.cellFactoryProperty().set(new Callback<Carousel<ImageHandle>, CarouselCell<ImageHandle>>() {
@Override
public CarouselCell<ImageHandle> call(final Carousel<ImageHandle> carousel) {
CarouselCell<ImageHandle> carouselCell = new CarouselCell<ImageHandle>() {
@Override
protected void updateItem(ImageHandle item, boolean empty) {
super.updateItem(item, empty);
if(!empty) {
ImageView image = item.getImage();
image.setPreserveRatio(true);
image.fitWidthProperty().bind(carousel.heightProperty().multiply(0.6));
image.fitHeightProperty().bind(carousel.heightProperty().multiply(0.6));
setGraphic(image);
}
else {
setGraphic(null);
}
}
};
carouselCell.setEffect(new Reflection());
return carouselCell;
}
});
borderPane.setTop(carousel);
borderPane.setBottom(createOptionGridPane(carousel));
stage.setScene(new Scene(borderPane));
stage.setWidth(800);
stage.setHeight(600);
stage.show();