Java 类javafx.scene.control.ScrollPaneBuilder 实例源码

项目:javafx-demos    文件:ScrollPaneCustomScrollBarDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();

    ScrollPane bodyScroll = ScrollPaneBuilder.create().fitToHeight(true)
               .fitToWidth(true)
               .minHeight(40)
               .build();

    VBox testvb = new VBox();
    for (int i = 0; i < 30; i++) {
    testvb.getChildren().add(new Label("hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello "));
    }
    bodyScroll.setContent(testvb);
    StackPane sp = new StackPane();
    sp.setMaxHeight(200);
    sp.getChildren().add(bodyScroll);

    StackPane sp1 = StackPaneBuilder.create().translateY(20).style("-fx-background-color:#86032B;").opacity(.59).maxHeight(200).maxWidth(200).build();
    root.getChildren().addAll(sp,sp1);
}
项目:javafx-demos    文件:ComboBoxPopupIssue.java   
@Override
public void start(Stage stage) throws Exception {
    ComboBox<String> comboBox = new ComboBox<>();
    comboBox.setItems(FXCollections.observableArrayList(Arrays.asList("One", "Two", "Three")));
    StackPane root = new StackPane();
    root.getChildren().add(
            ScrollPaneBuilder
                    .create()
                    .fitToHeight(true)
                    .fitToWidth(true)
                    .content(
                            StackPaneBuilder.create().minHeight(600).padding(new Insets(50, 20, 20, 20)).alignment(Pos.TOP_LEFT)
                                    .children(comboBox).build()).build());

    Scene scene = new Scene(root, Color.LINEN);
    stage.setTitle(this.getClass().getSimpleName());
    stage.setWidth(500);
    stage.setHeight(500);
    stage.setScene(scene);
    stage.show();
}
项目:javafx-demos    文件:ScrollPaneDisplacementDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 150; i++) {
        sb.append("test ");
    }
    // Logic starts
    VBox vb = new VBox();
    vb.setStyle("-fx-border-width:1px;-fx-border-color:red;");
    vb.setPadding(new Insets(30));
    Text lbl = TextBuilder.create().text(sb.toString()).wrappingWidth(150).build();
    ScrollPane scroll = ScrollPaneBuilder.create().maxWidth(width).maxHeight(height).minWidth(width).minHeight(height)
            .content(StackPaneBuilder.create().alignment(Pos.TOP_LEFT).minHeight(400).children(lbl).build()).build();
    // vb.getChildren().addAll(scroll);
    root.getChildren().add(
            GroupBuilder.create()
                    .children(StackPaneBuilder.create().style("-fx-border-width:1px;-fx-border-color:red;").children(scroll).build())
                    .build());
    // applySineWaveEffect(scroll);
    // applyCosWaveEffect(scroll);
    applyEffect(scroll);

}
项目:javafx-demos    文件:ImageLayoutsDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();
    // Logic starts
    propScroll = ScrollPaneBuilder.create().fitToHeight(true).fitToWidth(true).build();
    dock.getChildren().add(image);
    SplitPane sp = new SplitPane();
    sp.getItems().addAll(dock,propScroll);

    GridPane gp = GridPaneBuilder.create().vgap(10).hgap(10).padding(new Insets(10)).build();
    propScroll.setContent(gp);
    root.getChildren().add(sp);

    gp.addRow(0, new Label("X : "),getBindedTextField(image.xProperty()));
    gp.addRow(1, new Label("Y : "),getBindedTextField(image.yProperty()));
    gp.addRow(2, new Label("Layout-X : "),getBindedTextField(image.layoutXProperty()));
    gp.addRow(3, new Label("Layout-Y : "),getBindedTextField(image.layoutYProperty()));
    gp.addRow(4, new Label("Translate-X : "),getBindedTextField(image.translateXProperty()));
    gp.addRow(5, new Label("Translate-Y : "),getBindedTextField(image.translateYProperty()));

    gp.addRow(6, new Label("Fit Width : "),getBindedTextField(image.fitWidthProperty()));
    gp.addRow(7, new Label("Fit Height : "),getBindedTextField(image.fitHeightProperty()));
    gp.addRow(8, new Label("Scale-X : "),getBindedTextField(image.scaleXProperty()));
    gp.addRow(9, new Label("Scale-Y : "),getBindedTextField(image.scaleYProperty()));

    CheckBox cb = new CheckBox();
    image.preserveRatioProperty().bindBidirectional(cb.selectedProperty());
    gp.addRow(10, new Label("Preserve ratio : "),cb);
    }
项目:javafx-demos    文件:DynamicTextAreaDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();
    // Logic starts
    VBox vb = new VBox();
    vb.setSpacing(10);

    final VBox layout = VBoxBuilder.create().build();
    layout.getChildren().add(new DynamicTextArea());

    Button btn = ButtonBuilder.create().text("Add").onAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent arg0) {
            layout.getChildren().add(new DynamicTextArea());
        }
    }).build();

    final GridPane gridPane = GridPaneBuilder.create()
            .styleClass("contact-details-gridpane")
            // [ARE] Further modification for CAEMR-2098. Setting minimum width to show labels even if application width is changed.
            .columnConstraints(ColumnConstraintsBuilder.create().hgrow(Priority.NEVER).minWidth(80).build(),
                    ColumnConstraintsBuilder.create().hgrow(Priority.ALWAYS).build(),
                    ColumnConstraintsBuilder.create().hgrow(Priority.NEVER).minWidth(100).build()).build();

    gridPane.addRow(0, new Label("hi"), layout, btn);

    root.getChildren().add(ScrollPaneBuilder.create().styleClass("contact-details-pane").hbarPolicy(ScrollBarPolicy.NEVER)
            .fitToWidth(true).content(gridPane).build());
}
项目:LJGM    文件:LJGM.java   
@Override
public void start(Stage primaryStage) throws Exception {
    if (false) {
        new GalleryCreator(galleryManager.getGalleries().get(0)).show();
        return;
    }
    logger.info("Setting up main stage...");
    this.ljgmStage = primaryStage;
    ljgmStage.setTitle(LJGMUtils.generateStageTitle("Starting..."));
    ljgmStage.getIcons().add(new Image("file:res/favicon.png"));

    // Create the scroll pane for the viewing area
    ScrollPane sp = ScrollPaneBuilder.create().content(view).hbarPolicy(ScrollBarPolicy.AS_NEEDED)
            .vbarPolicy(ScrollBarPolicy.AS_NEEDED).build();

    // Create the main border pane to host all the components
    // Center: viewing area, left: sidebar, bottom: status bar, top: menu
    // items
    // @formatter:off
    BorderPane bp = BorderPaneBuilder.create().center(sp).left(gallerySidebar).bottom(statusBar).top(createMenuBar()).build();
    // @formatter:on
    ljgmStage.setScene(new Scene(bp, 1000, 500));

    // Select the first gallery
    if (gallerySidebar.getListView().getItems().size() != 0) {
        view.setFocus(galleryManager.getGallery(gallerySidebar.removeImageCount(gallerySidebar.getListView().getItems()
                .get(0))));
        gallerySidebar.getListView().getSelectionModel().select(0);
    } else {
        view.setFocus(null);
    }

    logger.info("Main stage set up.");
    ljgmStage.show();
    logger.info("Done!");
}
项目:mars-sim    文件:Scroll2.java   
@Override
public void start(Stage stage) {

  String message = 
    "Earthrise at Christmas: " +
    "[Forty] years ago this Christmas, a turbulent world " +
    "looked to the heavens for a unique view of our home "  +
    "planet. This photo of Earthrise over the lunar horizon " +
    "was taken by the Apollo 8 crew in December 1968, showing " +
    "Earth for the first time as it appears from deep space. " +
    "Astronauts Frank Borman, Jim Lovell and William Anders " +
    "had become the first humans to leave Earth orbit, " +
    "entering lunar orbit on Christmas Eve. In a historic live " +
    "broadcast that night, the crew took turns reading from " +
    "the Book of Genesis, closing with a holiday wish from " +
    "Commander Borman: \"We close with good night, good luck, " +
    "a Merry Christmas, and God bless all of you -- all of " +
    "you on the good Earth.\"";

  // Reference to the Text
  Text textRef = TextBuilder.create()
    .layoutY(100)
    .textOrigin(VPos.TOP)
    .textAlignment(TextAlignment.JUSTIFY)
    .wrappingWidth(400)
    .text(message)
    .fill(Color.rgb(187, 195, 107))
    .font(Font.font("SansSerif", FontWeight.BOLD, 24))
    .build();

   // Provides the animated scrolling behavior for the text
  TranslateTransition transTransition = TranslateTransitionBuilder.create()
    .duration(new Duration(75000))
    .node(textRef)
    .toY(-820)
    .interpolator(Interpolator.LINEAR)
    .cycleCount(Timeline.INDEFINITE)
    .build();

  Scene scene  = SceneBuilder.create()
    .width(516)
    .height(387)
    .root(
      GroupBuilder.create()
        .children(
          ImageViewBuilder.create()
            .image(new Image("http://projavafx.com/images/earthrise.jpg"))
            .build(),
          ScrollPaneBuilder.create()
            .layoutX(50)
            .layoutY(100)
            .prefWidth(440)
            .prefHeight(200)
            .hbarPolicy(ScrollBarPolicy.NEVER)
            .vbarPolicy(ScrollBarPolicy.NEVER)
            .pannable(true)
            .content(textRef)
            .style("-fx-background-color: transparent;")
            .build()
        )
        .build()
    )
    .build();

  stage.setScene(scene);
  stage.setTitle("Hello Earthrise");
  stage.show();

  // Start the text animation
  transTransition.play();
}
项目:javafx-demos    文件:DisplacementMapBannerDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();
    // Logic starts
    for (int i = 0; i < BANNER_NB; i++) {
        maps[i] = new FloatMap(W, H);
    }

    for (int x = 0; x < W/2; x++) {
        double angle = Math.PI * x / 50.0;
        float v = (float) (Math.sin(angle) / 20.0);
        float scaledX = x / W;
        System.out.println(x + " : " + angle + " : " + v);
        for (int y = 0; y < H; y++) {
            float scaledY = y / H;
            float scaledV = (float) (v - (1.0 - scaledY) / 20.0);
            maps[0].setSamples(x, y, 0, 0);
            maps[1].setSamples(x, y, v);
            maps[2].setSamples(x, y, 0, scaledV);
            maps[3].setSamples(x, y, v, scaledV);
            double sq = Math.sqrt(x * x + y * y);
            maps[4].setSamples(x, y, (float) ((115 - sq) / 115.0));
            maps[5].setSamples(x, y, 0, (float) (scaledX * scaledY * 4.7));
            maps[6].setSamples(x, y, 0, (float) (scaledX * 0.5));
            maps[7].setSamples(x, y, (float) (scaledY * 0.5));
        }
    }

    String[] messages = { "Reference", "Accordion", "Wavy Text", "Dizzy Text", "OxoXoxO", "XoxOxoX", "13463463", "2346346436" };
    VBox vb = new VBox();
    vb.setSpacing(15);
    for (int k = 0; k < messages.length; k++) {
        vb.getChildren().add(
                GroupBuilder.create().effect(DisplacementMapBuilder.create().mapData(maps[k]).wrap(bTestWrap).build()).cache(true)
                        .children(new Banner(messages[k])).build());
    }
    root.getChildren().add(
            ScrollPaneBuilder.create().fitToHeight(true).fitToWidth(true).style("-fx-background-color:transparent;").content(vb)
                    .build());
}