Java Code Examples for javafx.scene.control.ScrollPane#setPrefHeight()

The following examples show how to use javafx.scene.control.ScrollPane#setPrefHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QualityControlViewPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Display a dialog containing all Rule objects registered with the Quality
 * Control View and which matched for a given identifier.
 *
 * @param owner The owner Node
 * @param identifier The identifier of the graph node being displayed.
 * @param rules The list of rules measured against this graph node.
 */
private static void showRuleDialog(final Node owner, final String identifier, final List<Pair<Integer, String>> rules) {
    final ScrollPane sp = new ScrollPane();
    sp.setPrefHeight(512);
    sp.setPrefWidth(512);
    sp.setFitToWidth(true);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);

    final VBox vbox = new VBox();
    vbox.prefWidthProperty().bind(sp.widthProperty());
    vbox.setPadding(Insets.EMPTY);
    for (final Pair<Integer, String> rule : rules) {
        final String[] t = rule.getValue().split("§");

        final String quality = rule.getKey() == 0 ? Bundle.MSG_NotApplicable() : "" + rule.getKey();
        final String title = String.format("%s - %s", quality, t[0]);

        final Text content = new Text(t[1]);
        content.wrappingWidthProperty().bind(sp.widthProperty().subtract(16)); // Subtract a random number to avoid the vertical scrollbar.

        final TitledPane tp = new TitledPane(title, content);
        tp.prefWidthProperty().bind(vbox.widthProperty());
        tp.setExpanded(false);
        tp.setWrapText(true);

        vbox.getChildren().add(tp);
    }
    sp.setContent(vbox);

    final Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setHeaderText(String.format(Bundle.MSG_QualtyControlRules(), identifier));
    alert.getDialogPane().setContent(sp);
    alert.setResizable(true);
    alert.show();
}
 
Example 2
Source File: AttributeEditorPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * multi value pane showing multiple values for an attribute
 *
 * @param attribute
 * @param attributePane
 * @param values
 */
private void createMultiValuePane(final AttributeData attribute, final TitledPane attributePane, final Object[] values) {
    final VBox dataAndMoreButtonBox = new VBox(5); // 5 = spacing

    final ScrollPane multiValuePane = new ScrollPane();

    multiValuePane.setFitToWidth(true);

    final ObservableList<Object> listData = FXCollections.observableArrayList();

    if (values.length > VISIBLE_ROWS) {
        for (int i = 0; i < VISIBLE_ROWS; i++) {
            listData.add(values[i]);
        }
    } else {
        listData.addAll(values);
    }
    final ListView<Object> listView = createListView(attribute, listData);
    final boolean moreToLoad = values.length > VISIBLE_ROWS;
    int visibleRow = moreToLoad ? VISIBLE_ROWS : listData.size();
    listView.setPrefHeight((CELL_HEIGHT * visibleRow) + 2); // +2 because if it is == then there is still a scrollbar.
    multiValuePane.setPrefHeight((CELL_HEIGHT * visibleRow) + 1);
    multiValuePane.setContent(listView);
    multiValuePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    dataAndMoreButtonBox.setAlignment(Pos.CENTER);
    dataAndMoreButtonBox.setPadding(new Insets(0, 0, 5, 0));
    dataAndMoreButtonBox.getChildren().add(multiValuePane);
    if (moreToLoad) {
        Button loadMoreButton = createLoadMoreButton(dataAndMoreButtonBox, attribute);
        dataAndMoreButtonBox.getChildren().add(loadMoreButton);
    }
    dataAndMoreButtonBox.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
        if (event.isShortcutDown() && (event.getCode() == KeyCode.A)) {
            listView.getSelectionModel().selectAll();
            event.consume();
        }
    });
    attributePane.setContent(dataAndMoreButtonBox);
}
 
Example 3
Source File: HTMLEditorApp.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    root.getChildren().addAll(vRoot);
}
 
Example 4
Source File: VertexGraphLabelsEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    // get all vertex attributes currently in the graph
    final ReadableGraph rg = GraphManager.getDefault().getActiveGraph().getReadableGraph();
    try {
        for (int i = 0; i < rg.getAttributeCount(GraphElementType.VERTEX); i++) {
            attributeNames.add(rg.getAttributeName(rg.getAttribute(GraphElementType.VERTEX, i)));
        }
    } finally {
        rg.release();
    }
    attributeNames.sort(String::compareTo);

    HBox labelTitles = new HBox();
    final Label attrLabel = new Label("Attribute");
    attrLabel.setAlignment(Pos.CENTER);
    attrLabel.setPrefWidth(150);
    final Label colorLabel = new Label("Colour");
    colorLabel.setPrefWidth(40);
    colorLabel.setAlignment(Pos.CENTER);
    final Label sizeLabel = new Label("Size");
    sizeLabel.setPrefWidth(50);
    sizeLabel.setAlignment(Pos.CENTER);
    final Label positionLabel = new Label("Position");
    positionLabel.setPrefWidth(115);
    positionLabel.setAlignment(Pos.CENTER);
    labelTitles.getChildren().addAll(attrLabel, colorLabel, sizeLabel, positionLabel);
    labelPaneContent.setPadding(new Insets(5));
    labelPaneContent.getChildren().addAll(labelTitles, labelEntries);

    final ScrollPane labelsScrollPane = new ScrollPane();
    labelsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    labelsScrollPane.setPrefHeight(200);
    labelsScrollPane.setPrefWidth(400);
    labelsScrollPane.setContent(labelPaneContent);

    addButton.setOnAction(e -> {
        new LabelEntry(labels, labelEntries, attributeNames.isEmpty() ? "" : attributeNames.get(0), ConstellationColor.LIGHT_BLUE, 1);
        addButton.setDisable(labels.size() == GraphLabels.MAX_LABELS);
        update();
    });
    final Label addButtonLabel = new Label("Add Label");
    final FlowPane addPane = new FlowPane();
    addPane.setHgap(10);
    addPane.setAlignment(Pos.CENTER_RIGHT);
    addPane.getChildren().addAll(addButtonLabel, addButton);

    final VBox controls = new VBox(10);
    controls.setPrefWidth(400);
    controls.getChildren().addAll(labelsScrollPane, addPane);

    return controls;
}
 
Example 5
Source File: TransactionGraphLabelsEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    // get all transaction attributes currently in the graph
    final ReadableGraph rg = GraphManager.getDefault().getActiveGraph().getReadableGraph();
    try {
        for (int i = 0; i < rg.getAttributeCount(GraphElementType.TRANSACTION); i++) {
            attributeNames.add(rg.getAttributeName(rg.getAttribute(GraphElementType.TRANSACTION, i)));
        }
    } finally {
        rg.release();
    }
    attributeNames.sort(String::compareTo);

    final HBox labelTitles = new HBox();
    final Label attrLabel = new Label("Attribute");
    attrLabel.setAlignment(Pos.CENTER);
    attrLabel.setPrefWidth(150);
    final Label colorLabel = new Label("Colour");
    colorLabel.setPrefWidth(40);
    colorLabel.setAlignment(Pos.CENTER);
    final Label sizeLabel = new Label("Size");
    sizeLabel.setPrefWidth(50);
    sizeLabel.setAlignment(Pos.CENTER);
    final Label positionLabel = new Label("Position");
    positionLabel.setPrefWidth(115);
    positionLabel.setAlignment(Pos.CENTER);
    labelTitles.getChildren().addAll(attrLabel, colorLabel, sizeLabel, positionLabel);
    labelPaneContent.setPadding(new Insets(5));
    labelPaneContent.getChildren().addAll(labelTitles, labelEntries);

    final ScrollPane labelsScrollPane = new ScrollPane();
    labelsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    labelsScrollPane.setPrefHeight(200);
    labelsScrollPane.setPrefWidth(400);
    labelsScrollPane.setContent(labelPaneContent);

    addButton.setOnAction(e -> {
        new LabelEntry(labels, labelEntries, attributeNames.isEmpty() ? "" : attributeNames.get(0), ConstellationColor.LIGHT_BLUE, 1);
        addButton.setDisable(labels.size() == GraphLabels.MAX_LABELS);
        update();
    });
    final Label addButtonLabel = new Label("Add Label");
    final FlowPane addPane = new FlowPane();
    addPane.setHgap(10);
    addPane.setAlignment(Pos.CENTER_RIGHT);
    addPane.getChildren().addAll(addButtonLabel, addButton);

    final VBox controls = new VBox(10);
    controls.setPrefWidth(400);
    controls.getChildren().addAll(labelsScrollPane, addPane);

    return controls;
}
 
Example 6
Source File: OnlyPopupOverFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void init() {

		this.setTitle("测试");
		this.setWidth(380);
		this.setHeight(300);
		this.setRadius(10);

		this.setCenter(rootVBox);

		topBox.setPrefHeight(20);

		rootVBox.setStyle("-fx-background-color:rgba(255, 255, 255, 1)");
		rootVBox.getChildren().add(topBox);
		rootVBox.getChildren().add(centerBox);

		button.setPrefHeight(70);
		button.setPrefWidth(200);
		button.setLayoutX(20);
		button.setLayoutY(140);

		centerBox.getChildren().add(button);

		// po.setDetached(false);
		// po.setDetachable(false);
		po.setArrowLocation(OnlyPopupOver.ArrowLocation.TOP_CENTER);
		po.setContentNode(createContent());
		po.setArrowSize(0);

		StackPane sp = new StackPane();

		// autoCheckBox.setFocusTraversable(true);
		ScrollPane scrollPane = new ScrollPane();
		scrollPane.setBackground(Background.EMPTY);
		scrollPane.setMinWidth(150);
		scrollPane.setPrefWidth(250);
		scrollPane.setPrefHeight(360);

		scrollPane.setContent(sp);
		// scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
		scrollPane.widthProperty().addListener((Observable observable) -> {
			// sp.setPrefWidth(scrollPane.getWidth()-20);
		});

	}
 
Example 7
Source File: WebViewFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void init() {

		this.setTitle("测试");
		this.setWidth(380);
		this.setHeight(300);
		this.setRadius(10);

		this.setCenter(rootVBox);

		topBox.setPrefHeight(20);

		rootVBox.setStyle("-fx-background-color:rgba(255, 255, 255, 1)");
		rootVBox.getChildren().add(topBox);
		rootVBox.getChildren().add(centerBox);

		button.setPrefHeight(70);
		button.setPrefWidth(200);
		button.setLayoutX(20);
		button.setLayoutY(140);

		centerBox.getChildren().add(button);

		// po.setDetached(false);
		// po.setDetachable(false);
		po.setArrowLocation(OnlyPopupOver.ArrowLocation.TOP_CENTER);
		po.setContentNode(createContent());
		po.setArrowSize(0);

		StackPane sp = new StackPane();

		// autoCheckBox.setFocusTraversable(true);
		ScrollPane scrollPane = new ScrollPane();
		scrollPane.setBackground(Background.EMPTY);
		scrollPane.setMinWidth(150);
		scrollPane.setPrefWidth(250);
		scrollPane.setPrefHeight(360);

		scrollPane.setContent(sp);
		// scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
		scrollPane.widthProperty().addListener((Observable observable) -> {
			// sp.setPrefWidth(scrollPane.getWidth()-20);
		});

	}
 
Example 8
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    getChildren().addAll(vRoot);

    // REMOVE ME
    // Workaround for RT-16781 - HTML editor in full screen has wrong border
    javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
    for(javafx.scene.Node child: grid.getChildren()) {
        javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
    }
    // END REMOVE ME
}
 
Example 9
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    getChildren().addAll(vRoot);

    // REMOVE ME
    // Workaround for RT-16781 - HTML editor in full screen has wrong border
    javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
    for(javafx.scene.Node child: grid.getChildren()) {
        javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
    }
    // END REMOVE ME
}