List of usage examples for javafx.scene.control ScrollPane setPrefSize
public void setPrefSize(double prefWidth, double prefHeight)
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);/* w w w . j a va 2 s. c om*/ 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
@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 a2s . co 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: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/* w ww . jav a 2 s . c om*/ */ 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; }