Example usage for javafx.scene.layout BorderPane setMinSize

List of usage examples for javafx.scene.layout BorderPane setMinSize

Introduction

In this page you can find the example usage for javafx.scene.layout BorderPane setMinSize.

Prototype

public void setMinSize(double minWidth, double minHeight) 

Source Link

Document

Convenience method for overriding the region's computed minimum width and height.

Usage

From source file:photobooth.views.ExplorerPane.java

private BorderPane createImageView(final File imageFile) {
    // DEFAULT_THUMBNAIL_WIDTH is a constant you need to define
    // The last two arguments are: preserveRatio, and use smooth (slower)
    // resizing//from  w ww  .  j a v  a  2s .co m
    ExplorerPane explorerPane = this;
    ImageView imageView = null;
    BorderPane borderPane = new BorderPane();
    try {
        borderPane.setMaxSize(100, 100);
        borderPane.setMinSize(100, 100);
        FileInputStream fileInputStream = new FileInputStream(imageFile);
        final Image image = new Image(fileInputStream, 100, 100, true, true);
        imageView = new ImageView(image);
        fileInputStream.close();
        imageView.getStyleClass().add("image-view");
        borderPane.setCenter(imageView);
        //imageView.setFitWidth(80);
        imageView.setOnMouseClicked(new EventHandler<MouseEvent>() {

            @Override
            public void handle(MouseEvent mouseEvent) {

                if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {

                    if (mouseEvent.getClickCount() == 1) {
                        Global.getInstance().setSceneRoot(LoadingPane.getInstance());

                        Platform.runLater(() -> {
                            new Thread(new Runnable() {

                                @Override
                                public void run() {
                                    ImagePane.getInstance().init(explorerPane, imageFile);
                                    Global.getInstance().setSceneRoot(ImagePane.getInstance());
                                }
                            }).start();
                        });

                    }
                }
            }
        });
    } catch (FileNotFoundException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex);
    }
    return borderPane;
}