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

The following examples show how to use javafx.scene.control.ScrollPane#setPrefWidth() . 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: 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 3
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 4
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 5
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 6
Source File: MainLayout.java    From redtorch with MIT License 4 votes vote down vote up
private void createLayout() {

		vBox.getChildren().add(crearteMainMenuBar());
		// 左右切分布局------------------------
		SplitPane horizontalSplitPane = new SplitPane();
		horizontalSplitPane.setDividerPositions(0.5);
		vBox.getChildren().add(horizontalSplitPane);
		VBox.setVgrow(horizontalSplitPane, Priority.ALWAYS);

		// 左右切分布局----左侧上下切分布局---------
		SplitPane leftVerticalSplitPane = new SplitPane();
		leftVerticalSplitPane.setDividerPositions(0.4);
		horizontalSplitPane.getItems().add(leftVerticalSplitPane);
		leftVerticalSplitPane.setOrientation(Orientation.VERTICAL);
		// 左右切分布局----左侧上下切分布局----上布局-----
		SplitPane leftTopHorizontalSplitPane = new SplitPane();
		leftVerticalSplitPane.getItems().add(leftTopHorizontalSplitPane);

		HBox leftTopRithtPane = new HBox();
		Node orderPanelLayoutNode = orderPanelLayout.getNode();
		HBox.setHgrow(orderPanelLayoutNode, Priority.ALWAYS);

		ScrollPane marketDetailsScrollPane = new ScrollPane();
		Node marketDetailsNode = marketDetailsLayout.getNode();
		marketDetailsScrollPane.setContent(marketDetailsNode);
		marketDetailsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
		marketDetailsScrollPane.setPrefWidth(253);
		marketDetailsScrollPane.setMinWidth(253);
		marketDetailsScrollPane.setMaxWidth(253);
		leftTopRithtPane.getChildren().addAll(marketDetailsScrollPane, orderPanelLayoutNode);
		leftTopRithtPane.setMaxWidth(680);
		leftTopRithtPane.setPrefWidth(680);

		leftTopHorizontalSplitPane.getItems().addAll(tickLayout.getNode(), leftTopRithtPane);
		SplitPane.setResizableWithParent(leftTopRithtPane, false);

		// 左右切分布局----左侧上下切分布局----下布局-----
		TabPane leftBootomTabPane = new TabPane();
		leftVerticalSplitPane.getItems().add(leftBootomTabPane);

		Tab orderTab = new Tab("定单");
		leftBootomTabPane.getTabs().add(orderTab);
		orderTab.setClosable(false);

		orderTab.setContent(orderLayout.getNode());

		Tab tradeTab = new Tab("成交");
		leftBootomTabPane.getTabs().add(tradeTab);
		tradeTab.setClosable(false);

		tradeTab.setContent(tradeLayout.getNode());

		// 左右切分布局----右侧TAB布局-------------
		TabPane rightTabPane = new TabPane();
		horizontalSplitPane.getItems().add(rightTabPane);

		Tab portfolioInvestmentTab = new Tab("投资组合");
		rightTabPane.getTabs().add(portfolioInvestmentTab);
		portfolioInvestmentTab.setClosable(false);

		SplitPane portfolioVerticalSplitPane = new SplitPane();
		portfolioInvestmentTab.setContent(portfolioVerticalSplitPane);
		portfolioVerticalSplitPane.setOrientation(Orientation.VERTICAL);
		VBox.setVgrow(portfolioVerticalSplitPane, Priority.ALWAYS);

		VBox portfolioVBox = new VBox();
		portfolioVBox.getChildren().add(combinationLayout.getNode());

		portfolioVBox.getChildren().add(accountLayout.getNode());

		VBox.setVgrow(accountLayout.getNode(), Priority.ALWAYS);

		portfolioVerticalSplitPane.getItems().add(portfolioVBox);

		portfolioVerticalSplitPane.getItems().add(positionLayout.getNode());

		Tab allContractTab = new Tab("全部合约");
		allContractTab.setContent(contractLayout.getNode());
		rightTabPane.getTabs().add(allContractTab);
		allContractTab.setClosable(false);

		// 状态栏------------------------------
		vBox.getChildren().add(createStatusBar());
	}
 
Example 7
Source File: Palette.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** Create UI elements
 *  @return Top-level Node of the UI
 */
@SuppressWarnings("unchecked")
public Node create()
{
    final VBox palette = new VBox();

    final Map<WidgetCategory, Pane> palette_groups = createWidgetCategoryPanes(palette);
    groups = palette_groups.values();
    createWidgetEntries(palette_groups);

    final ScrollPane palette_scroll = new ScrollPane(palette);
    palette_scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    palette_scroll.setFitToWidth(true);

    // TODO Determine the correct size for the main node
    // Using 2*PREFERRED_WIDTH was determined by trial and error
    palette_scroll.setMinWidth(PREFERRED_WIDTH + 12);
    palette_scroll.setPrefWidth(PREFERRED_WIDTH);

    // Copy the widgets, i.e. the children of each palette_group,
    // to the userData.
    // Actual children are now updated based on search by widget name
    palette_groups.values().forEach(group -> group.setUserData(new ArrayList<Node>(group.getChildren())));

    final TextField searchField = new ClearingTextField();
    searchField.setPromptText(Messages.SearchTextField);
    searchField.setTooltip(new Tooltip(Messages.WidgetFilterTT));
    searchField.setPrefColumnCount(9);
    searchField.textProperty().addListener( ( observable, oldValue, search_text ) ->
    {
        final String search = search_text.toLowerCase().trim();
        palette_groups.values().stream().forEach(group ->
        {
            group.getChildren().clear();
            final List<Node> all_widgets = (List<Node>)group.getUserData();
            if (search.isEmpty())
                group.getChildren().setAll(all_widgets);
            else
                group.getChildren().setAll(all_widgets.stream()
                                                      .filter(node ->
                                                      {
                                                         final String text = ((ToggleButton) node).getText().toLowerCase();
                                                         return text.contains(search);
                                                      })
                                                     .collect(Collectors.toList()));
        });
    });
    HBox.setHgrow(searchField, Priority.NEVER);

    final HBox toolsPane = new HBox(6);
    toolsPane.setAlignment(Pos.CENTER_RIGHT);
    toolsPane.setPadding(new Insets(6));
    toolsPane.getChildren().add(searchField);

    BorderPane paletteContainer = new BorderPane();
    paletteContainer.setTop(toolsPane);
    paletteContainer.setCenter(palette_scroll);

    return paletteContainer;
}