Example usage for javafx.scene.control ScrollPane setFitToWidth

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

Introduction

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

Prototype

public final void setFitToWidth(boolean value) 

Source Link

Usage

From source file:Main.java

License:asdf

@Override
public void start(Stage stage) {
    stage.setWidth(500);// w  ww .j a v  a2s.  com
    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);//  www.  ja va2  s  .  c  om
    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:io.uploader.drive.auth.webbrowser.SimpleBrowserImpl.java

public SimpleBrowserImpl(Stage stage, String url) throws IOException {

    super();/*from  w w  w  .  java 2  s  . co  m*/

    Preconditions.checkNotNull(stage);

    this.stage = stage;
    stage.setTitle("Drive Uploader - Authentication");
    UiUtils.setStageAppSize(stage);
    Scene scene = new Scene(new Group());

    AnchorPane root = new AnchorPane();

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

    /*
    Menu settingsMenu = new Menu ("Settings") ;
    MenuItem proxy = new MenuItem ("Proxy") ;
    settingsMenu.getItems().add(proxy) ;
    MenuBar menuBar = new MenuBar () ;
    menuBar.getMenus().add(settingsMenu) ;
    proxy.setOnAction(new EventHandler<ActionEvent> () {
            
     @Override
     public void handle(ActionEvent event) {
    try {
       ProxySettingDialog dlg = new ProxySettingDialog (stage, Configuration.INSTANCE) ;
       dlg.showDialog();
    } catch (IOException e) {
       logger.error("Error occurred while opening the proxy setting dialog", e);
    }
     }});*/

    FXMLLoader mainMenuLoader = new FXMLLoader(getClass().getResource("/fxml/MainMenu.fxml"));
    VBox mainMenuBar = (VBox) mainMenuLoader.load();
    AnchorPane.setTopAnchor(mainMenuBar, 0.0);
    AnchorPane.setLeftAnchor(mainMenuBar, 0.0);
    AnchorPane.setRightAnchor(mainMenuBar, 0.0);
    MainMenuController mainMenuController = mainMenuLoader.<MainMenuController>getController();
    mainMenuController.setOwner(stage);
    mainMenuController.setConfiguration(Configuration.INSTANCE);
    mainMenuController.hideAccountMenu(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(browser);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);

    if (StringUtils.isNotEmpty(url)) {
        goTo(url);
    }

    if (DriveUploader.isMacOsX()) {
        AnchorPane.setTopAnchor(scrollPane, 5.0);
    } else {
        AnchorPane.setTopAnchor(scrollPane, 35.0);
    }
    AnchorPane.setLeftAnchor(scrollPane, 5.0);
    AnchorPane.setRightAnchor(scrollPane, 5.0);
    AnchorPane.setBottomAnchor(scrollPane, 5.0);

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

    stage.setScene(scene);
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

private void createDialogItems() {
    Validate.notNull(this.logReader); // Will be used to initialize input field values

    // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables.
    final GridPane gp = new GridPane();
    gp.setAlignment(Pos.BASELINE_LEFT);/*  w w w.  j a va  2s  .  co m*/
    gp.setHgap(10d);
    gp.setVgap(15d);
    gp.setPadding(new Insets(5d));
    final ColumnConstraints column1 = new ColumnConstraints();
    final ColumnConstraints column2 = new ColumnConstraints();
    column1.setHgrow(Priority.NEVER);
    column2.setHgrow(Priority.SOMETIMES);
    gp.getColumnConstraints().addAll(column1, column2);
    this.insertConfigItemsIntoGrid(gp, this.createConfigurationForm());
    final TitledPane configPane = new TitledPane("Edit Configuration", gp);
    configPane.setGraphic(Icons.getIconGraphics("pencil"));
    configPane.setCollapsible(false);

    final VBox lines = this.createRunForm();
    final TitledPane testPane = new TitledPane("Test Configuration", lines);
    testPane.setGraphic(Icons.getIconGraphics("script_go"));
    testPane.setCollapsible(false);

    final VBox panes = new VBox(configPane, testPane);
    panes.setSpacing(10d);
    final ScrollPane sp = new ScrollPane(panes);
    sp.setPadding(new Insets(10d));
    sp.setFitToWidth(true);
    this.setCenter(sp);
    // CHECKSTYLE:ON
}

From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java

private void createDialogItems() {
    final TitledPane configPane = this.createPanelForConfiguration();
    final TitledPane runPane = this.createPanelForLaunchingTests();
    final VBox panes = new VBox(configPane, runPane);
    final double insetsOfScrollPane = 10d;
    final double spacingOfPanes = insetsOfScrollPane;
    panes.setSpacing(spacingOfPanes);//from  www  . j a v  a 2 s . c o m
    final ScrollPane sp = new ScrollPane(panes);
    sp.setPadding(new Insets(insetsOfScrollPane));
    sp.setFitToWidth(true);
    this.setCenter(sp);
}

From source file:main.Content.java

public void showTreeView() {
    try {//from   w ww.jav  a 2 s  .c o  m
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Main.class.getResource("view/TreePane.fxml"));
        AnchorPane activityPaneOverview = (AnchorPane) loader.load();

        TreeViewController controller = loader.getController();
        ScrollPane scrollPane = new ScrollPane();

        controller.setMainApp(this);
        controller.setTableData(data);
        controller.startTreeView();

        TreeView<String> treeView = controller.getTree();

        scrollPane.setContent(treeView);
        treeView.autosize();

        activityPaneOverview.getStylesheets()
                .add(Main.class.getResource("view/DarkTheme.css").toExternalForm());

        activityPaneOverview.getChildren().add(scrollPane);
        activityPaneOverview.setTopAnchor(scrollPane, 10.0);
        activityPaneOverview.setLeftAnchor(scrollPane, 10.0);
        activityPaneOverview.setRightAnchor(scrollPane, 10.0);
        activityPaneOverview.setBottomAnchor(scrollPane, 10.0);

        scrollPane.setFitToHeight(true);
        scrollPane.setFitToWidth(true);

        rootLayout.setLeft(activityPaneOverview);

        System.out.println("showTreeOveerview u therrit" + index);

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:qupath.lib.gui.tma.TMASummaryViewer.java

private Pane createSidePane() {
    BorderPane pane = new BorderPane();

    TabPane tabPane = new TabPane();

    kmDisplay = new KaplanMeierDisplay(null, null, null, null);
    BorderPane paneKaplanMeier = new BorderPane();
    paneKaplanMeier.setCenter(kmDisplay.getView());
    paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10));
    //      comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty());
    comboMainMeasurement.setMaxWidth(Double.MAX_VALUE);
    comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc."));

    GridPane kmTop = new GridPane();
    kmTop.add(new Label("Score"), 0, 0);
    kmTop.add(comboMainMeasurement, 1, 0);
    kmTop.add(new Label("Survival type"), 0, 1);
    kmTop.add(comboSurvival, 1, 1);//from  ww  w  .  java 2 s. c o  m
    comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)"));
    comboSurvival.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS);
    GridPane.setHgrow(comboSurvival, Priority.ALWAYS);
    kmTop.setHgap(5);
    paneKaplanMeier.setTop(kmTop);
    //      kmDisplay.setOrientation(Orientation.VERTICAL);

    histogramDisplay = new HistogramDisplay(model, false);

    comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        histogramDisplay.refreshCombo();
        histogramDisplay.showHistogram(n);
        updateSurvivalCurves();
    });
    comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        histogramDisplay.refreshHistogram();
        scatterPane.updateChart();
        updateSurvivalCurves();
    });
    comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        updateSurvivalCurves();
    });

    // Create a Tab for showing images
    BorderPane paneImages = new BorderPane();
    CheckBox cbShowOverlay = new CheckBox("Show overlay");
    imageAvailability.addListener((c, v, n) -> {
        if (n == ImageAvailability.OVERLAY_ONLY)
            cbShowOverlay.setSelected(true);
        else if (n == ImageAvailability.IMAGE_ONLY)
            cbShowOverlay.setSelected(false);
        cbShowOverlay.setDisable(n != ImageAvailability.BOTH);
    });
    ListView<TMAEntry> listImages = new ListView<>();
    listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache));
    listImages.widthProperty().addListener((v, o, n) -> listImages.refresh());
    listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;");
    table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> {
        List<TMAEntry> entries = new ArrayList<>();
        for (TreeItem<TMAEntry> item : e.getList()) {
            if (item.getChildren().isEmpty()) {
                if (item.getValue().hasImage() || item.getValue().hasOverlay())
                    entries.add(item.getValue());
            } else {
                for (TreeItem<TMAEntry> item2 : item.getChildren()) {
                    if (item2.getValue().hasImage() || item2.getValue().hasOverlay())
                        entries.add(item2.getValue());
                }
            }
            listImages.getItems().setAll(entries);
        }
    });
    cbShowOverlay.setAlignment(Pos.CENTER);
    cbShowOverlay.setMaxWidth(Double.MAX_VALUE);
    cbShowOverlay.setPadding(new Insets(5, 5, 5, 5));
    cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh());
    paneImages.setCenter(listImages);
    paneImages.setTop(cbShowOverlay);

    // Determine visibility based upon whether there are any images to show
    //      Tab tabImages = new Tab("Images", paneImages);

    ScrollPane scrollPane = new ScrollPane(paneKaplanMeier);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    Tab tabSurvival = new Tab("Survival", scrollPane);
    tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()),
            //            tabImages,
            new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()),
            tabSurvival);
    tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);

    //      if (imageAvailability.get() != ImageAvailability.NONE)
    //         tabPane.getTabs().add(1, tabImages);
    //      
    //      imageAvailability.addListener((c, v, n) -> {
    //         if (n == ImageAvailability.NONE)
    //            tabPane.getTabs().remove(tabImages);
    //         else if (!tabPane.getTabs().contains(tabImages))
    //            tabPane.getTabs().add(1, tabImages);
    //      });

    //      tabSurvival.visibleProperty().bind(
    //            Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns)
    //            );

    pane.setCenter(tabPane);

    pane.setMinWidth(350);

    return pane;
}