javafx.scene.layout.GridPane Java Examples

The following examples show how to use javafx.scene.layout.GridPane. 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: GenericRootAndDatasetStructure.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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 File: NewTradeProtocolLaunchWindow.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #3
Source File: JFXHelper.java    From Schillsaver with 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 #4
Source File: RadioButtonDrivenTextFieldsPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #5
Source File: FormBuilder.java    From bisq with 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 #6
Source File: AddPreferenceStage.java    From marathonv5 with 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 #7
Source File: AbstractFileCreator.java    From jmonkeybuilder with 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 #8
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void addOptionsGroup() {
    advancedOptionsGroup = addTitledGroupBg(gridPane, ++gridRow, 1, Res.get("shared.advancedOptions"), Layout.COMPACT_GROUP_DISTANCE);

    advancedOptionsBox = new HBox();
    advancedOptionsBox.setSpacing(40);

    GridPane.setRowIndex(advancedOptionsBox, gridRow);
    GridPane.setColumnIndex(advancedOptionsBox, 0);
    GridPane.setHalignment(advancedOptionsBox, HPos.LEFT);
    GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(advancedOptionsBox);

    advancedOptionsBox.getChildren().addAll(getTradeFeeFieldsBox());
}
 
Example #9
Source File: Example1.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
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
Source File: Generator.java    From jsilhouette with 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 #11
Source File: NewsView.java    From bisq with 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 #12
Source File: TablePane.java    From Intro-to-Java-Programming with 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 #13
Source File: BoardNameDialog.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #14
Source File: ProgressIndicatorSample.java    From marathonv5 with 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 #15
Source File: RregulloPunen.java    From Automekanik with GNU General Public License v3.0 5 votes vote down vote up
public RregulloPunen(int id, boolean kryer, DritarjaKryesore dk){
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setResizable(false);
    stage.setTitle("Rregullo");
    HBox btn = new HBox(5);
    btn.getChildren().addAll(btnOk, btnAnulo);
    btn.setAlignment(Pos.CENTER_RIGHT);
    GridPane grid = new GridPane();
    grid.add(cbKryer, 0, 0);
    grid.add(btn, 0, 1);
    grid.setVgap(10);
    grid.setAlignment(Pos.CENTER);

    cbKryer.setSelected(kryer);

    btnOk.setOnAction(e -> {
        azhurno(id);
        new Thread(new Runnable() {
            @Override
            public void run() {
                dk.filtroFinancat(new TextField(""));
                dk.loadThread(dk.lblQmimi4);
                dk.loadThreadMes(dk.lblQmimi3);
            }
        }).start();
    });

    btnAnulo.setOnAction(e -> stage.close());

    Scene scene = new Scene(grid, 230, 100);
    scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
    stage.setScene(scene);
    stage.show();
}
 
Example #16
Source File: ExtractSubAnimationDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createContent(@NotNull final GridPane root) {
    super.createContent(root);

    final Label nameLabel = new Label(Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_NAME + ":");
    nameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT));

    nameField = new TextField();
    nameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT));

    final Label startFrameLabel = new Label(Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_START_FRAME + ":");
    startFrameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT));

    startFrameField = new IntegerTextField();
    startFrameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT));

    final Label endFrameLabel = new Label(Messages.MANUAL_EXTRACT_ANIMATION_DIALOG_END_FRAME + ":");
    endFrameLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT));

    endFrameField = new IntegerTextField();
    endFrameField.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT));

    root.add(nameLabel, 0, 0);
    root.add(nameField, 1, 0);
    root.add(startFrameLabel, 0, 1);
    root.add(startFrameField, 1, 1);
    root.add(endFrameLabel, 0, 2);
    root.add(endFrameField, 1, 2);

    FXUtils.addClassTo(nameLabel, startFrameLabel, endFrameLabel, CssClasses.DIALOG_DYNAMIC_LABEL);
    FXUtils.addClassTo(nameField, endFrameField, startFrameField, CssClasses.DIALOG_FIELD);
}
 
Example #17
Source File: DataCollectionUI.java    From SONDY with GNU General Public License v3.0 5 votes vote down vote up
final public void collectDataUI(){
    GridPane gridLEFT = new GridPane();
    Label queryLabel = new Label("Query");
    UIUtils.setSize(queryLabel,Main.columnWidthLEFT/2, 24);
    TextField queryField = new TextField();
    queryField.setPromptText("formatted query");
    UIUtils.setSize(queryField,Main.columnWidthLEFT/2, 24);
    Label durationLabel = new Label("Duration");
    UIUtils.setSize(durationLabel,Main.columnWidthLEFT/2, 24);
    TextField durationField = new TextField();
    durationField.setPromptText("duration in days (e.g. 2)");
    UIUtils.setSize(durationField,Main.columnWidthLEFT/2, 24);
    Label datasetIDLabel = new Label("Dataset ID");
    UIUtils.setSize(datasetIDLabel,Main.columnWidthLEFT/2, 24);
    TextField datasetIDField = new TextField();
    datasetIDField.setPromptText("unique identifier");
    UIUtils.setSize(datasetIDField,Main.columnWidthLEFT/2, 24);
    
    gridLEFT.add(queryLabel,0,0);
    gridLEFT.add(queryField,1,0);
    gridLEFT.add(new Rectangle(0,3),0,1);
    gridLEFT.add(durationLabel,0,2);
    gridLEFT.add(durationField,1,2);
    gridLEFT.add(new Rectangle(0,3),0,3);
    gridLEFT.add(datasetIDLabel,0,4);
    gridLEFT.add(datasetIDField,1,4);
    
    Button button = new Button("Collect");
    UIUtils.setSize(button,Main.columnWidthRIGHT, 24);
    button.setAlignment(Pos.CENTER);
    VBox buttonBox = new VBox();
    buttonBox.setAlignment(Pos.CENTER);
    buttonBox.getChildren().add(button);
    
    HBox collectDataBOTH = new HBox(5);
    collectDataBOTH.getChildren().addAll(gridLEFT,buttonBox);
    grid.add(collectDataBOTH,0,8);
}
 
Example #18
Source File: LoginDialog.java    From HubTurbo with 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 #19
Source File: GenericBackendDialogN5.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
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 #20
Source File: PropertiesAction.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private Node createContent()
{
    final GridPane layout = new GridPane();
    layout.setHgap(5);
    layout.setVgap(5);

    int row = 0;

    final TextField filename = new TextField(file.getAbsolutePath());
    filename.setEditable(false);
    GridPane.setHgrow(filename, Priority.ALWAYS);
    layout.add(new Label(Messages.PropDlgPath), 0, row);
    layout.add(filename, 1, row);

    final TextField date = new TextField(TimestampFormats.MILLI_FORMAT.format(Instant.ofEpochMilli(file.lastModified())));
    date.setEditable(false);
    date.setMinWidth(200);
    GridPane.setHgrow(date, Priority.ALWAYS);
    layout.add(new Label(Messages.PropDlgDate), 0, ++row);
    layout.add(date, 1, row);

    if (!file.isDirectory())
    {
        final TextField size = new TextField(file.length() + " " + Messages.PropDlgBytes);
        size.setEditable(false);
        GridPane.setHgrow(size, Priority.ALWAYS);
        layout.add(new Label(Messages.PropDlgSize), 0, ++row);
        layout.add(size, 1, row);
    }

    layout.add(new Label(Messages.PropDlgPermissions), 0, ++row);
    layout.add(writable, 1, row);
    layout.add(executable, 1, ++row);

    writable.setSelected(file.canWrite());
    executable.setSelected(file.canExecute());

    return layout;
}
 
Example #21
Source File: SavesTabController.java    From SmartModInserter with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #22
Source File: TemplateBox.java    From DeskChan with 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 #23
Source File: FormBuilder.java    From bisq with 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 #24
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static CheckBox addLabelCheckBox(GridPane gridPane, int rowIndex, String title, double top) {
    CheckBox checkBox = new AutoTooltipCheckBox(title);
    GridPane.setRowIndex(checkBox, rowIndex);
    GridPane.setColumnIndex(checkBox, 0);
    GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(checkBox);

    return checkBox;
}
 
Example #25
Source File: RoleSelectionTest.java    From triplea with 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);
}
 
Example #26
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void addBusyAnimation() {
    BusyAnimation busyAnimation = new BusyAnimation();
    GridPane.setHalignment(busyAnimation, HPos.CENTER);
    GridPane.setRowIndex(busyAnimation, ++rowIndex);
    GridPane.setColumnSpan(busyAnimation, 2);
    gridPane.getChildren().add(busyAnimation);
}
 
Example #27
Source File: ProgressIndicatorSample.java    From marathonv5 with 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 #28
Source File: AuthenticatedPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void initialize() {

        GridPane.setHalignment(signOutButton, HPos.CENTER);
        authenticatedView.showingProperty().addListener((obs, oldValue, newValue) -> {
            if (newValue) {
                AppBar appBar = getApp().getAppBar();
                appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> 
                        getApp().getDrawer().open()));
                appBar.setTitleText("Authenticated");
                loadDetails();
            }
        });
    }
 
Example #29
Source File: SegmentMeshExporterDialog.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private int createCommonDialog(final GridPane contents)
{
	int row = 0;

	contents.add(new Label("Scale"), 0, row);
	contents.add(scale, 1, row);
	GridPane.setFillWidth(scale, true);
	++row;

	contents.add(new Label("Format"), 0, row);

	final List<String>           typeNames = Stream.of(FILETYPE.values()).map(FILETYPE::name).collect(Collectors
			.toList());
	final ObservableList<String> options   = FXCollections.observableArrayList(typeNames);
	fileFormats = new ComboBox<>(options);
	fileFormats.getSelectionModel().select(0);
	fileFormats.setMinWidth(0);
	fileFormats.setMaxWidth(Double.POSITIVE_INFINITY);
	contents.add(fileFormats, 1, row);
	fileFormats.maxWidth(300);
	GridPane.setFillWidth(fileFormats, true);
	GridPane.setHgrow(fileFormats, Priority.ALWAYS);

	++row;

	contents.add(new Label("Save to:"), 0, row);
	contents.add(filePath, 1, row);

	this.getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, ButtonType.OK);
	this.getDialogPane().lookupButton(ButtonType.OK).disableProperty().bind(this.isError);

	return row;
}
 
Example #30
Source File: ChartMeasurementSelector.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public ChartMeasurementSelector(final ParameterMeasurements plugin, final AbstractChartMeasurement dataSetMeasurement, final int requiredNumberOfChartMeasurements) {
    super();
    if (plugin == null) {
        throw new IllegalArgumentException("plugin must not be null");
    }

    final Label label = new Label("Selected Measurement: ");
    GridPane.setConstraints(label, 0, 0);
    chartMeasurementListView = new ListView<>(plugin.getChartMeasurements().filtered(t -> !t.equals(dataSetMeasurement)));
    GridPane.setConstraints(chartMeasurementListView, 1, 0);
    chartMeasurementListView.setOrientation(Orientation.VERTICAL);
    chartMeasurementListView.setPrefSize(-1, DEFAULT_SELECTOR_HEIGHT);
    chartMeasurementListView.setCellFactory(list -> new ChartMeasurementLabel());
    chartMeasurementListView.setPrefHeight(Math.max(2, plugin.getChartMeasurements().size()) * ROW_HEIGHT + 2.0);
    MultipleSelectionModel<AbstractChartMeasurement> selModel = chartMeasurementListView.getSelectionModel();
    if (requiredNumberOfChartMeasurements == 1) {
        selModel.setSelectionMode(SelectionMode.SINGLE);
    } else if (requiredNumberOfChartMeasurements >= 2) {
        selModel.setSelectionMode(SelectionMode.MULTIPLE);
    }

    // add default initially selected ChartMeasurements
    if (selModel.getSelectedIndices().isEmpty() && plugin.getChartMeasurements().size() >= requiredNumberOfChartMeasurements) {
        for (int i = 0; i < requiredNumberOfChartMeasurements; i++) {
            selModel.select(i);
        }
    }

    if (selModel.getSelectedIndices().size() < requiredNumberOfChartMeasurements && LOGGER.isWarnEnabled()) {
        LOGGER.atWarn().addArgument(plugin.getChartMeasurements().size()).addArgument(requiredNumberOfChartMeasurements).log("could not add default selection: required {} vs. selected {}");
    }

    if (requiredNumberOfChartMeasurements >= 1) {
        getChildren().addAll(label, chartMeasurementListView);
    }
}