Example usage for javafx.scene.control ScrollPane ScrollPane

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

Introduction

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

Prototype

public ScrollPane() 

Source Link

Document

Creates a new ScrollPane.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);/*from w ww  . j a v a 2  s  . c o  m*/

    Rectangle rect = new Rectangle(200, 200, Color.RED);
    ScrollPane s1 = new ScrollPane();
    s1.setPannable(true);
    s1.setPrefSize(120, 120);
    s1.setContent(rect);

    root.getChildren().add(s1);
    stage.show();
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setWidth(400);/*from w ww.j  av  a 2 s  .  com*/
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(browser);

    browser.getEngine().setOnAlert((WebEvent<String> wEvent) -> {
        System.out.println("Alert Event  -  Message:  " + wEvent.getData());
    });

    webEngine.load("http://java2s.com");

    scene.setRoot(scrollPane);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);//from w  w w.ja  v a2  s.  c  o  m

    Rectangle rect = new Rectangle(200, 200, Color.RED);
    ScrollPane s1 = new ScrollPane();
    s1.setPrefSize(120, 120);
    s1.setContent(rect);

    s1.vvalueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            System.out.println(new_val.intValue());
        }
    });
    s1.hvalueProperty().addListener(new ChangeListener<Number>() {
        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            System.out.println(new_val.intValue());
        }
    });
    root.getChildren().add(s1);
    stage.show();
}

From source file:Main.java

License:asdf

@Override
public void start(Stage stage) {
    stage.setWidth(500);// w w w.j ava  2s .  c  om
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(browser);
    webEngine.loadContent("<b>asdf</b>");

    root.getChildren().addAll(scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

License:asdf

@Override
public void start(Stage stage) {
    stage.setWidth(500);// ww  w .ja va  2 s.  c  o m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setFitToWidth(true);

    scrollPane.setContent(browser);
    webEngine.loadContent("<b>asdf</b>");

    root.getChildren().addAll(scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(final Stage primaryStage) {
    Group root = new Group();
    final TextArea textArea = TextAreaBuilder.create().prefWidth(400).wrapText(true).build();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(textArea);//from w  w w. j  a  va  2 s .  c  o  m
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefWidth(400);
    scrollPane.setPrefHeight(180);

    VBox vBox = VBoxBuilder.create().children(scrollPane).build();
    root.getChildren().add(vBox);
    primaryStage.setScene(new Scene(root, 500, 400));
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) throws Exception {
    ImageView imageView = new ImageView();
    ScrollPane scrollPane = new ScrollPane();
    DoubleProperty zoomProperty = new SimpleDoubleProperty(200);

    zoomProperty.addListener(new InvalidationListener() {
        @Override/*from   w w w  .j  av a2 s .c  om*/
        public void invalidated(Observable arg0) {
            imageView.setFitWidth(zoomProperty.get() * 2);
            imageView.setFitHeight(zoomProperty.get() * 3);
        }
    });
    scrollPane.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {
        @Override
        public void handle(ScrollEvent event) {
            if (event.getDeltaY() > 0) {
                zoomProperty.set(zoomProperty.get() * 1.2);
            } else if (event.getDeltaY() < 0) {
                zoomProperty.set(zoomProperty.get() / 1.1);
            }
        }
    });
    imageView.setImage(new Image("http://yourImageURL"));
    imageView.preserveRatioProperty().set(true);
    scrollPane.setContent(imageView);
    stage.setScene(new Scene(scrollPane, 400, 300));
    stage.show();
}

From source file:Main.java

License:asdf

@Override
public void start(Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);/*  w  w w .  j  a  v  a  2s  .c  om*/
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(browser);
    webEngine.loadContent("<b>asdf</b>");

    root.getChildren().addAll(scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

License:asdf

@Override
public void start(Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);/*from  w  w w  .  j  av  a  2  s.co m*/
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox root = new VBox();

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setStyle("-fx-background-color: white");

    scrollPane.setContent(browser);
    webEngine.loadContent("<b>asdf</b>");

    root.getChildren().addAll(scrollPane);
    scene.setRoot(root);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setWidth(400);//from   w  w  w  .  jav  a2s .c o m
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(browser);

    browser.getEngine().setOnAlert((WebEvent<String> wEvent) -> {
        System.out.println("Alert Event  -  Message:  " + wEvent.getData());
    });

    webEngine.load("http://java2s.com");

    final WebHistory history = webEngine.getHistory();
    history.getEntries().addListener(new ListChangeListener<WebHistory.Entry>() {
        @Override
        public void onChanged(Change<? extends Entry> c) {
            c.next();
            for (Entry e : c.getRemoved()) {
                System.out.println(e.getUrl());
            }
            for (Entry e : c.getAddedSubList()) {
                System.out.println(e.getUrl());
            }
        }
    });

    history.go(0);
    scene.setRoot(scrollPane);

    stage.setScene(scene);
    stage.show();
}