Java Code Examples for javafx.scene.layout.GridPane

The following examples show how to use javafx.scene.layout.GridPane. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
private Node createNode()
{
	final Node             groupField      = rootNode.get();
	final ComboBox<String> datasetDropDown = new ComboBox<>(datasetChoices);
	datasetDropDown.setPromptText(datasetPromptText);
	datasetDropDown.setEditable(false);
	datasetDropDown.valueProperty().bindBidirectional(dataset);
	datasetDropDown.disableProperty().bind(this.isDropDownReady);
	final GridPane grid = new GridPane();
	grid.add(groupField, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(groupField, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	final Button button = new Button("Browse");
	button.setOnAction(event -> onBrowseClicked.accept(grid.getScene()));
	grid.add(button, 1, 0);

	return grid;
}
 
Example 2
Source Project: marathonv5   Source File: AddPreferenceStage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Parent getContentPane() {
    VBox content = new VBox();
    content.getStyleClass().add("add-preference-stage");
    content.setId("addPreferenceStage");
    FormPane form = new FormPane("add-preference-stage-form", 3);
    integerValueField.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                integerValueField.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });
    StackPane pane = new StackPane(stringValueField, integerValueField, booleanValueField);
    pane.setAlignment(Pos.CENTER_LEFT);
    //@formatter:off
    form.addFormField("Property name:", nameField)
        .addFormField("Method:", typeComboBox, new Region())
        .addFormField("Value:", pane);
    //@formatter:on
    GridPane.setHgrow(typeComboBox, Priority.NEVER);
    VBox.setVgrow(form, Priority.ALWAYS);
    content.getChildren().addAll(form, buttonBar);
    return content;
}
 
Example 3
Source Project: bisq   Source File: FormBuilder.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, Label, VBox> addLabelWithSubText(GridPane gridPane,
                                                             int rowIndex,
                                                             String title,
                                                             String description,
                                                             double top) {
    Label label = new AutoTooltipLabel(title);
    Label subText = new AutoTooltipLabel(description);

    VBox vBox = new VBox();
    vBox.getChildren().setAll(label, subText);

    GridPane.setRowIndex(vBox, rowIndex);
    GridPane.setMargin(vBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(vBox);

    return new Tuple3<>(label, subText, vBox);
}
 
Example 4
Source Project: jsilhouette   Source File: Generator.java    License: Apache License 2.0 6 votes vote down vote up
private GridPane multiround_rectangle(Stage stage) {
    stage.setTitle("MultiRoundRectangle");
    GridPane grid = grid();
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0).getShape(), 0, 0);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 10).getShape(), 1, 0);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 10, 0, 0, 0).getShape(), 2, 0);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0, 10, 0, 0).getShape(), 3, 0);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0, 0, 10, 0).getShape(), 4, 0);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0, 0, 0, 10).getShape(), 5, 0);

    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 10, 10, 0, 0).getShape(), 0, 1);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0, 0, 10, 10).getShape(), 1, 1);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0, 10, 10, 0).getShape(), 2, 1);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 10, 0, 0, 10).getShape(), 3, 1);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 10, 0, 10, 0).getShape(), 4, 1);
    grid.add(new MultiRoundRectangle(50, 50, 50, 50, 0, 10, 0, 10).getShape(), 5, 1);

    return grid;
}
 
Example 5
Source Project: bisq   Source File: NewsView.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void initialize() {
    root.setSpacing(20);

    AnchorPane bisqDAOPane = createBisqDAOContent();
    HBox.setHgrow(bisqDAOPane, Priority.SOMETIMES);
    Separator separator = new Separator();
    separator.setOrientation(Orientation.VERTICAL);
    HBox.setHgrow(separator, Priority.NEVER);
    GridPane bisqDAOOnTestnetPane = createBisqDAOOnTestnetContent();
    HBox.setHgrow(bisqDAOOnTestnetPane, Priority.SOMETIMES);
    Pane spacer = new Pane();
    HBox.setHgrow(spacer, Priority.ALWAYS);

    root.getChildren().addAll(bisqDAOPane, separator, bisqDAOOnTestnetPane, spacer);
}
 
Example 6
Source Project: Intro-to-Java-Programming   Source File: TablePane.java    License: MIT License 6 votes vote down vote up
/** Return a grid pane of rectangle info */
private GridPane getGrid(TextField x, TextField y, 
	TextField width, TextField height) {
	GridPane gridPane = new GridPane();
	gridPane.setHgap(5);
	gridPane.setVgap(2);
	gridPane.add(new Label("X:"), 0, 0);
	gridPane.add(x, 1, 0);
	gridPane.add(new Label("Y:"), 0, 1);
	gridPane.add(y, 1, 1);
	gridPane.add(new Label("Width:"), 0, 2);
	gridPane.add(width, 1, 2);
	gridPane.add(new Label("Height:"), 0, 3);
	gridPane.add(height, 1, 3);
	return  gridPane;
}
 
Example 7
Source Project: Schillsaver   Source File: JFXHelper.java    License: MIT License 6 votes vote down vote up
/**
 * Creates a GridPane with only one column, but where there are as many rows as there are controls passed
 * to the function.
 *
 * Ex:
 *      If you pass in two controls, then there will be one column with two rows where each row uses 50%
 *      of the height.
 *
 * Ex:
 *      If you pass in four controls, then there will be one column with four rows where each row uses 25%
 *      of the height.
 *
 * @param controls
 *          The controls.
 *
 * @return
 *          The pane.
 */
public static GridPane createVerticalGridPane(final Control... controls) {
    if (controls.length == 0) {
        return new GridPane();
    }

    final GridPane pane = new GridPane();
    final double sectionHeight = 100.0 / controls.length;

    for (final Control ignored : controls) {
        final RowConstraints constraints = new RowConstraints();
        constraints.setPercentHeight(sectionHeight);

        pane.getRowConstraints().add(constraints);
    }

    for (int i = 0 ; i < controls.length ; i++) {
        pane.add(controls[i], 0, i);
    }

    return pane;
}
 
Example 8
private void createContent() {
    HBox content = new HBox();
    content.setMinWidth(680);
    content.setAlignment(Pos.TOP_LEFT);
    content.setSpacing(40);

    VBox accountSigning = getFeatureBox(Res.get("popup.news.launch.accountSigning.headline"),
            Res.get("popup.news.launch.accountSigning.description"),
            "image-account-signing-screenshot",
            "https://docs.bisq.network/payment-methods#account-signing");

    VBox newTradeProtocol = getFeatureBox(Res.get("popup.news.launch.ntp.headline"),
            Res.get("popup.news.launch.ntp.description"),
            "image-new-trade-protocol-screenshot",
            "https://docs.bisq.network/trading-rules");

    content.getChildren().addAll(accountSigning, new Separator(Orientation.VERTICAL), newTradeProtocol);

    GridPane.setMargin(content, new Insets(10, 0, 0, 0));
    GridPane.setRowIndex(content, ++rowIndex);
    GridPane.setColumnSpan(content, 2);
    GridPane.setHgrow(content, Priority.ALWAYS);
    gridPane.getChildren().add(content);
}
 
Example 9
private void buildAndShowMainWindow(Stage primaryStage) {
    primaryStage.setTitle("Hello World!!");
    GridPane gridPane = new GridPane();
    gridPane.setAlignment(Pos.CENTER);
    gridPane.setHgap(10);
    gridPane.setVgap(10);
    gridPane.setPadding(new Insets(25, 25, 25, 25));

    button = new Button("Click me!");
    gridPane.add(button,1,1);

    text = new TextField();
    gridPane.add(text, 2, 1);

    clockLabel = new Label();
    gridPane.add(clockLabel, 1,2, 2, 1);

    Scene scene = new Scene(gridPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 10
public void addRow(RadioButton radio, Region field, Text helpIcon) {
    requireNotNullArg(radio, "Cannot add a null radio");
    requireNotNullArg(field, "Cannot add a null field");
    GridPane.setValignment(radio, VPos.BOTTOM);
    GridPane.setValignment(field, VPos.BOTTOM);
    GridPane.setHalignment(radio, HPos.LEFT);
    GridPane.setHalignment(field, HPos.LEFT);
    GridPane.setFillWidth(field, true);
    field.setPrefWidth(300);
    field.setDisable(true);
    radio.selectedProperty().addListener((o, oldVal, newVal) -> {
        field.setDisable(!newVal);
        if (newVal) {
            field.requestFocus();
        }
    });
    radio.setToggleGroup(group);
    add(radio, 0, rows);
    add(field, 1, rows);
    if (nonNull(helpIcon)) {
        add(helpIcon, 2, rows);
    }
    rows++;

}
 
Example 11
Source Project: jmonkeybuilder   Source File: AbstractFileCreator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create settings of the creating file.
 *
 * @param root the root
 */
@FxThread
protected void createSettings(@NotNull final GridPane root) {

    final Label fileNameLabel = new Label(getFileNameLabelText() + ":");
    fileNameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT));

    fileNameField = new TextField();
    fileNameField.prefWidthProperty().bind(root.widthProperty());
    fileNameField.textProperty().addListener((observable, oldValue, newValue) -> validateFileName());
    fileNameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT));

    root.add(fileNameLabel, 0, 0);
    root.add(fileNameField, 1, 0);

    FXUtils.addClassTo(fileNameLabel, CssClasses.DIALOG_DYNAMIC_LABEL);
    FXUtils.addClassTo(fileNameField, CssClasses.DIALOG_FIELD);
}
 
Example 12
Source Project: Noexes   Source File: MainController.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void showMessage(Throwable ex) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle(ex.getClass().getName());
        alert.setHeaderText(ex.getClass().getSimpleName());
        alert.setContentText(ex.getMessage());


// Create expandable Exception.
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        ex.printStackTrace(pw);
        String exceptionText = sw.toString();

        Label label = new Label("The exception stacktrace was:");

        TextArea textArea = new TextArea(exceptionText);
        textArea.setEditable(false);
        textArea.setWrapText(true);

        textArea.setMaxWidth(Double.MAX_VALUE);
        textArea.setMaxHeight(Double.MAX_VALUE);
        GridPane.setVgrow(textArea, Priority.ALWAYS);
        GridPane.setHgrow(textArea, Priority.ALWAYS);

        GridPane expContent = new GridPane();
        expContent.setMaxWidth(Double.MAX_VALUE);
        expContent.add(label, 0, 0);
        expContent.add(textArea, 0, 1);

// Set expandable Exception into the dialog pane.
        alert.getDialogPane().setExpandableContent(expContent);

        alert.showAndWait();
    }
 
Example 13
Source Project: bisq   Source File: FormBuilder.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple2<Label, TextFieldWithCopyIcon> addTopLabelTextFieldWithCopyIcon(GridPane gridPane,
                                                                                    int rowIndex,
                                                                                    String title,
                                                                                    String value,
                                                                                    double top,
                                                                                    String styleClass) {
    TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon(styleClass);
    textFieldWithCopyIcon.setText(value);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, textFieldWithCopyIcon, top);

    return new Tuple2<>(topLabelWithVBox.first, textFieldWithCopyIcon);
}
 
Example 14
private Node initializeNode(
		final Node rootNode,
		final String datasetPromptText,
		final Node browseNode)
{
	final MenuButton datasetDropDown = new MenuButton();
	final StringBinding datasetDropDownText = Bindings.createStringBinding(() -> dataset.get() == null || dataset.get().length() == 0 ? datasetPromptText : datasetPromptText + ": " + dataset.get(), dataset);
	final ObjectBinding<Tooltip> datasetDropDownTooltip = Bindings.createObjectBinding(() -> Optional.ofNullable(dataset.get()).map(Tooltip::new).orElse(null), dataset);
	datasetDropDown.tooltipProperty().bind(datasetDropDownTooltip);
	datasetDropDown.disableProperty().bind(this.isN5Valid.not());
	datasetDropDown.textProperty().bind(datasetDropDownText);
	datasetChoices.addListener((ListChangeListener<String>) change -> {
		final MatchSelection matcher = MatchSelection.fuzzySorted(datasetChoices, s -> {
			dataset.set(s);
			datasetDropDown.hide();
		});
		LOG.debug("Updating dataset dropdown to fuzzy matcher with choices: {}", datasetChoices);
		final CustomMenuItem menuItem = new CustomMenuItem(matcher, false);
		// clear style to avoid weird blue highlight
		menuItem.getStyleClass().clear();
		datasetDropDown.getItems().setAll(menuItem);
		datasetDropDown.setOnAction(e -> {datasetDropDown.show(); matcher.requestFocus();});
	});
	final GridPane grid = new GridPane();
	grid.add(rootNode, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(rootNode, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	grid.add(browseNode, 1, 0);

	return grid;
}
 
Example 15
Source Project: marathonv5   Source File: FormPane.java    License: Apache License 2.0 5 votes vote down vote up
public FormPane addFormField(String text, Node field, int colSpan, int rowSpan) {
    Label label = new Label(text);
    String labelId = idText(text);
    label.setId(labelId);
    GridPane.setValignment(label, VPos.TOP);
    int column = 0;
    add(label, column++, currentRow, 1, 1);
    field.setId(labelId + "-field-1");
    setFormConstraints(field);
    GridPane.setValignment(field, VPos.TOP);
    add(field, column++, currentRow, colSpan, rowSpan);
    currentRow += rowSpan;
    column = 0;
    return this;
}
 
Example 16
Source Project: marathonv5   Source File: ProgressIndicatorSample.java    License: Apache License 2.0 5 votes vote down vote up
public ProgressIndicatorSample() {
    super(400,400);
    
    GridPane g = new GridPane();

    ProgressIndicator p1 = new ProgressIndicator();
    p1.setPrefSize(50, 50);

    ProgressIndicator p2 = new ProgressIndicator();
    p2.setPrefSize(50, 50);
    p2.setProgress(0.25F);

    ProgressIndicator p3 = new ProgressIndicator();
    p3.setPrefSize(50, 50);
    p3.setProgress(0.5F);

    ProgressIndicator p4 = new ProgressIndicator();
    p4.setPrefSize(50, 50);
    p4.setProgress(1.0F);

    g.add(p1, 1, 0);
    g.add(p2, 0, 1);
    g.add(p3, 1, 1);
    g.add(p4, 2, 1);

    g.setHgap(40);
    g.setVgap(40);
    
    getChildren().add(g);
}
 
Example 17
Source Project: Intro-to-Java-Programming   Source File: Exercise_16_08.java    License: MIT License 5 votes vote down vote up
/** Return a grid pane of circle info */
protected GridPane getGrid(
	TextField centerX, TextField centerY, TextField r) {
	GridPane gridPane = new GridPane();
	gridPane.setHgap(5);
	gridPane.setVgap(2);
	gridPane.add(new Label("Center x:"), 0, 0);
	gridPane.add(centerX, 1, 0);
	gridPane.add(new Label("Center y:"), 0, 1);
	gridPane.add(centerY, 1, 1);
	gridPane.add(new Label("Radius:"), 0, 2);
	gridPane.add(r, 1, 2);
	return  gridPane;
}
 
Example 18
Source Project: gef   Source File: DotHTMLLabelJavaFxNode.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void applyTextAlignAttributesOnTdPane(GridPane wrapper,
		HtmlTag td) {
	String hAlign = unquotedValueForAttr(
			DotHtmlLabelHelper.getAttributeForTag(td, "align")); //$NON-NLS-1$
	String vAlign = unquotedValueForAttr(
			DotHtmlLabelHelper.getAttributeForTag(td, "valign")); //$NON-NLS-1$

	if ("text".equalsIgnoreCase(hAlign)) { //$NON-NLS-1$
		GridPane.setHgrow(wrapper.getChildren().get(0), Priority.ALWAYS);
	}

	wrapper.setAlignment(posForTd(hAlign, vAlign));
}
 
Example 19
Source Project: BlockMap   Source File: Pin.java    License: MIT License 5 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	content.add(new Label("Position:"), 0, 2);
	content.add(new Label(spawn.toString()), 1, 2);

	info.setContentNode(content);
	return info;
}
 
Example 20
Source Project: constellation   Source File: LineStyleEditorFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setHgap(CONTROLS_DEFAULT_HORIZONTAL_SPACING);

    final Label lineStyleLabel = new Label("Line Style:");
    final ObservableList<LineStyle> lineStyles = FXCollections.observableArrayList(LineStyle.values());
    lineStyleComboBox = new ComboBox<>(lineStyles);
    final Callback<ListView<LineStyle>, ListCell<LineStyle>> cellFactory = (final ListView<LineStyle> p) -> new ListCell<LineStyle>() {
        @Override
        protected void updateItem(final LineStyle item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                setText(item.name());
            }
        }
    };
    lineStyleComboBox.setCellFactory(cellFactory);
    lineStyleComboBox.setButtonCell(cellFactory.call(null));
    lineStyleLabel.setLabelFor(lineStyleComboBox);
    lineStyleComboBox.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });

    controls.addRow(0, lineStyleLabel, lineStyleComboBox);
    return controls;
}
 
Example 21
/**
 * Build up a single columns of buttons
 * @return pane with radio buttons
 */
private Pane buildNormalColLayout()
{
	GridPane boxPane = new GridPane();
	int numButtons = avaRadioButton.length;
	for (int row = 0; row < numButtons; ++row)
	{
		boxPane.add(avaRadioButton[row], 0, row);
	}
	return boxPane;
}
 
Example 22
Source Project: GitFx   Source File: GitFxDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void gitExceptionDialog(String title, String header, String content, Exception e) {

    Alert alert = new Alert(AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(header);
    alert.setContentText(content);

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();
    Label label = new Label("Exception stack trace:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);
    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
}
 
Example 23
Source Project: bisq   Source File: GUIUtil.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple2<ComboBox<TradeCurrency>, Integer> addRegionCountryTradeCurrencyComboBoxes(GridPane gridPane,
                                                                                               int gridRow,
                                                                                               Consumer<Country> onCountrySelectedHandler,
                                                                                               Consumer<TradeCurrency> onTradeCurrencySelectedHandler) {
    gridRow = addRegionCountry(gridPane, gridRow, onCountrySelectedHandler);

    ComboBox<TradeCurrency> currencyComboBox = FormBuilder.addComboBox(gridPane, ++gridRow,
            Res.get("shared.currency"));
    currencyComboBox.setPromptText(Res.get("list.currency.select"));
    currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies()));

    currencyComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(TradeCurrency currency) {
            return currency.getNameAndCode();
        }

        @Override
        public TradeCurrency fromString(String string) {
            return null;
        }
    });
    currencyComboBox.setDisable(true);

    currencyComboBox.setOnAction(e ->
            onTradeCurrencySelectedHandler.accept(currencyComboBox.getSelectionModel().getSelectedItem()));

    return new Tuple2<>(currencyComboBox, gridRow);
}
 
Example 24
Source Project: bisq   Source File: DaoLaunchWindow.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private void createContent() {
    HBox slidingContentWithPagingBox = new HBox();
    slidingContentWithPagingBox.setPadding(new Insets(30, 0, 0, 0));
    slidingContentWithPagingBox.setAlignment(Pos.CENTER);
    Button prevButton = getIconButton(MaterialDesignIcon.ARROW_LEFT, "dao-launch-paging-button");
    prevButton.setOnAction(event -> {
        autoPlayTimeline.stop();
        goToPrevSection();
    });
    Button nextButton = getIconButton(MaterialDesignIcon.ARROW_RIGHT, "dao-launch-paging-button");
    nextButton.setOnAction(event -> {
        autoPlayTimeline.stop();
        goToNextSection();
    });
    VBox slidingContent = new VBox();
    slidingContent.setMinWidth(616);
    slidingContent.setSpacing(20);
    sectionDescriptionLabel = new Label();
    sectionDescriptionLabel.setTextAlignment(TextAlignment.CENTER);
    sectionDescriptionLabel.getStyleClass().add("dao-launch-description");
    sectionDescriptionLabel.setMaxWidth(562);
    sectionDescriptionLabel.setWrapText(true);


    selectedSection = sections.get(currentSectionIndex.get());

    sectionDescriptionLabel.setText(selectedSection.description);
    sectionScreenshot = new ImageView();
    sectionScreenshot.setOpacity(0);
    sectionScreenshot.setId(selectedSection.imageId);

    slidingContent.setAlignment(Pos.CENTER);
    slidingContent.getChildren().addAll(sectionDescriptionLabel, sectionScreenshot);
    slidingContentWithPagingBox.getChildren().addAll(prevButton, slidingContent, nextButton);

    GridPane.setRowIndex(slidingContentWithPagingBox, ++rowIndex);
    GridPane.setColumnSpan(slidingContentWithPagingBox, 2);
    GridPane.setHgrow(slidingContent, Priority.ALWAYS);
    gridPane.getChildren().add(slidingContentWithPagingBox);
}
 
Example 25
private static void setupGridPane(GridPane grid) {
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(5);
    grid.setVgap(5);
    grid.setPadding(new Insets(25));
    grid.setPrefSize(360, 60);
    grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
}
 
Example 26
Source Project: HubTurbo   Source File: LoginDialog.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Configures the central grid pane before it's used.
 */
private static void setupGridPane(GridPane grid) {
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(7);
    grid.setVgap(10);
    grid.setPadding(new Insets(25));
    grid.setPrefSize(390, 100);
    grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
    applyColumnConstraints(grid, 20, 16, 33, 2, 29);
}
 
Example 27
@Override
public void init() {
    tab.setContent(root);
    saves.setItems(store.getSaves());
    saves.setCellFactory(saveListView -> {
        return new ListCell<Save>() {
            @Override
            protected void updateItem(Save save, boolean empty) {
                Runnable r = () -> {
                    super.updateItem(save, empty);
                    if (!empty) {
                        setText(null);
                        GridPane pane = new GridPane();
                        pane.setHgap(10);
                        pane.setVgap(4);
                        pane.setPadding(new Insets(0, 10, 0, 10));
                        ImageView screenshot = new ImageView(save.getScreenshot());
                        screenshot.setPreserveRatio(true);
                        screenshot.setFitWidth(75);
                        pane.add(screenshot, 0, 0, 1, 2);
                        Label name = new Label(save.getName());
                        Label fileName = new Label(save.getPath().getFileName().toString());
                        pane.add(name, 1, 0, 1, 1);
                        pane.add(fileName, 1, 1, 1, 1);
                        setGraphic(pane);
                    }
                };

                if (Platform.isFxApplicationThread()) {
                    r.run();
                } else {
                    Platform.runLater(r);
                }
            }
        };
    });
}
 
Example 28
Source Project: DeskChan   Source File: TemplateBox.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private void printHTML(Pane node, int indent){
	if (node == null) return;

	String _indent = "";
	for (int i=0; i<indent; i++) _indent += "  ";

	String itemClass = getClassName(node);
	switch (itemClass){
		case "grid-pane": {
			System.out.println(_indent + "<table realclass=\"GridPane\"" + (node.getId() != null ? (" id=\"" + node.getId() + "\"") : "") + ">");
			GridPane grid = (GridPane) node;
			int w=0,h=0;
			for (Node item : grid.getChildren()) {
				Integer index = GridPane.getRowIndex(item);
				if (index != null) h = Math.max(h, index + 1);
				index = GridPane.getColumnIndex(item);
				if (index != null) w = Math.max(w, index + 1);
			}
			for (int i=0; i<h; i++) {
				System.out.println(_indent+" <tr>");
				for (int j=0; j<w; j++) {
					Node cell = getNodeFromGridPane(grid, i, j);
					System.out.println(_indent+"  <td>");
					printHTML(cell, indent + 2);
					System.out.println(_indent+"  </td>");
				}
				System.out.println(_indent+"</tr>");
			}
			System.out.println(_indent + "</table>");
		} break;
		default: {
			String c = node.getClass().getSimpleName();
			System.out.println(_indent + "<" + c + (node.getId() != null ? (" id=\"" + node.getId() + "\"") : "") + " class=\"" + itemClass + "\">");
			for (Node child : node.getChildren())
				printHTML(child, indent + 1);
			System.out.println(_indent + "</"+c+">");
		} break;
	}
}
 
Example 29
Source Project: bisq   Source File: FormBuilder.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static AddressTextField addAddressTextField(GridPane gridPane, int rowIndex, String title, double top) {
    AddressTextField addressTextField = new AddressTextField(title);
    GridPane.setRowIndex(addressTextField, rowIndex);
    GridPane.setColumnIndex(addressTextField, 0);
    GridPane.setMargin(addressTextField, new Insets(top + 20, 0, 0, 0));
    gridPane.getChildren().add(addressTextField);

    return addressTextField;
}
 
Example 30
Source Project: triplea   Source File: RoleSelectionTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private List<ComboBox<String>> mockComboBoxes() {
  final ComboBox<String> globalBox = mock(ComboBox.class);
  final ComboBox<String> comboBox1 = mock(ComboBox.class);
  final ComboBox<String> comboBox2 = mock(ComboBox.class);

  final GridPane gridPane = mock(GridPane.class);
  when(gridPane.getChildren())
      .thenReturn(FXCollections.observableArrayList(mock(Node.class), comboBox1, comboBox2));

  roleSelection.setFactionGrid(gridPane);
  roleSelection.setAllSelectorCheckbox(globalBox);
  return List.of(globalBox, comboBox1, comboBox2);
}