Example usage for javafx.scene.control ScrollPane setVmax

List of usage examples for javafx.scene.control ScrollPane setVmax

Introduction

In this page you can find the example usage for javafx.scene.control ScrollPane setVmax.

Prototype

public final void setVmax(double value) 

Source Link

Usage

From source file:de.ifsr.adam.ImageGenerator.java

/**
 * Main method for generating an Preview out of a report with it results.
 *
 * @param resultReport The report with it results
 * @return returns true if the generation and saving of the image was successful, false
 * otherwise/*from  ww w.  j  a  v  a 2s . co m*/
 */
public Scene generatePreview(JSONArray resultReport) {
    log.info("Preview generation has started");
    VBox vbox = generateImageVBox(resultReport);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    scrollPane.setContent(vbox);

    //Gets the screen resulution for scaling.
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int width = gd.getDisplayMode().getWidth();
    int height = gd.getDisplayMode().getHeight();

    scrollPane.setVmax(100.0);
    scrollPane.setPrefSize(width * 0.65, height * 0.8); //TODO Can I do this better?

    ((Group) scene.getRoot()).getChildren().add(scrollPane);
    scene.getStylesheets().add(this.stylesheetURI.toString());

    //The Observer for resizing the scrollpane when the window changes.
    scene.widthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth,
                Number newSceneWidth) {
            scrollPane.setPrefWidth(newSceneWidth.doubleValue());
        }
    });

    //The Observer for resizing the scrollpane when the window changes.
    scene.heightProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight,
                Number newSceneHeight) {
            scrollPane.setPrefHeight(newSceneHeight.doubleValue());
        }
    });

    log.info("End of Preview generation");
    return scene;
}