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

The following examples show how to use javafx.scene.control.ScrollPane#setMinWidth() . 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: 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 2
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 3
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 4
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;
}