Example usage for javafx.scene.layout BorderPane setMaxSize

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

Introduction

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

Prototype

public void setMaxSize(double maxWidth, double maxHeight) 

Source Link

Document

Convenience method for overriding the region's computed maximum 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  w  w. java2 s . com*/
    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;
}