Java Code Examples for javafx.scene.layout.VBox#setMargin()

The following examples show how to use javafx.scene.layout.VBox#setMargin() . 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: CheckListFormNode.java    From marathonv5 with Apache License 2.0 8 votes vote down vote up
private VBox createDescriptionField() {
    VBox descriptionFieldBox = new VBox();
    TextArea descriptionArea = new TextArea();
    descriptionArea.setPrefRowCount(4);
    descriptionArea.textProperty().addListener((observable, oldValue, newValue) -> {
        fireContentChanged();
        checkList.setDescription(descriptionArea.getText());
    });
    descriptionArea.setEditable(mode.isSelectable());
    descriptionFieldBox.getChildren().addAll(new Label("Description"), descriptionArea);
    HBox.setHgrow(descriptionArea, Priority.ALWAYS);
    VBox.setMargin(descriptionFieldBox, new Insets(5, 10, 5, 5));
    descriptionArea.setText(checkList.getDescription());
    HBox.setHgrow(descriptionArea, Priority.ALWAYS);
    HBox.setHgrow(descriptionFieldBox, Priority.ALWAYS);
    return descriptionFieldBox;
}
 
Example 2
Source File: ADCProjectInitWindow.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
public NewProjectTab() {
	tfProjectName.setPrefWidth(200d);
	tfProjectName.setPromptText("untitled");
	tfProjectDescription.setPrefRowCount(6);

	final VBox root = getTabVbox(10);

	final Label lblCreateNewProject = new Label(bundle.getString("new_project_title"));
	VBox.setMargin(lblCreateNewProject, new Insets(0, 0, 10, 0));
	final Label lblProjectName = new Label(bundle.getString("project_name"), tfProjectName);
	lblProjectName.setContentDisplay(ContentDisplay.RIGHT);
	final HBox hboxProjectDescription = new HBox(5, new Label(bundle.getString("new_project_description")), tfProjectDescription);

	root.getChildren().addAll(lblCreateNewProject, lblProjectName, hboxProjectDescription);

	tabNew.setContent(root);
}
 
Example 3
Source File: Builders.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
public static void setVBoxPosition(Region element, double width, double height, Insets margin){

        if(width == -1){
            HBox.setHgrow(element, Priority.ALWAYS);
            element.setMaxWidth(Double.MAX_VALUE);
        }else if(width != 0){
            element.setPrefWidth(width);
            element.minWidthProperty().bind(new SimpleDoubleProperty(width));
        }
        if(height == -1){
            VBox.setVgrow(element, Priority.ALWAYS);
        }else if(height != 0){
            element.setPrefHeight(height);
            element.minHeightProperty().bind(new SimpleDoubleProperty(height));
        }
        VBox.setMargin(element, margin);
    }
 
Example 4
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, InputTextField, ToggleButton> addTopLabelInputTextFieldSlideToggleButton(GridPane gridPane,
                                                                                                     int rowIndex,
                                                                                                     String title,
                                                                                                     String toggleButtonTitle) {

    InputTextField inputTextField = new InputTextField();
    ToggleButton toggleButton = new JFXToggleButton();
    toggleButton.setText(toggleButtonTitle);
    VBox.setMargin(toggleButton, new Insets(4, 0, 0, 0));

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

    topLabelWithVBox.second.getChildren().add(toggleButton);

    return new Tuple3<>(topLabelWithVBox.first, inputTextField, toggleButton);
}
 
Example 5
Source File: Controller.java    From xdat_editor with MIT License 5 votes vote down vote up
private Tab createTab(Field listField) {
    Tab tab = new Tab(listField.getName());

    SplitPane pane = new SplitPane();

    TextField filter = TextFields.createClearableTextField();
    VBox.setMargin(filter, new Insets(2));
    TreeView<Object> elements = createTreeView(listField, filter.textProperty());
    VBox.setVgrow(elements, Priority.ALWAYS);
    PropertySheet properties = createPropertySheet(elements);

    pane.getItems().addAll(new VBox(filter, elements), properties);
    pane.setDividerPositions(0.3);

    tab.setContent(wrap(pane));

    return tab;
}
 
Example 6
Source File: OfferBookChartView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void initialize() {
    createListener();

    final Tuple3<VBox, Label, AutocompleteComboBox<CurrencyListItem>> currencyComboBoxTuple = addTopLabelAutocompleteComboBox(Res.get("shared.currency"), 0);
    this.currencyComboBox = currencyComboBoxTuple.third;
    this.currencyComboBox.setCellFactory(GUIUtil.getCurrencyListItemCellFactory(Res.get("shared.oneOffer"),
            Res.get("shared.multipleOffers"), model.preferences));

    createChart();

    VBox.setMargin(chartPane, new Insets(0, 0, 5, 0));

    Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleBuy = getOfferTable(OfferPayload.Direction.BUY);
    Tuple4<TableView<OfferListItem>, VBox, Button, Label> tupleSell = getOfferTable(OfferPayload.Direction.SELL);
    buyOfferTableView = tupleBuy.first;
    sellOfferTableView = tupleSell.first;

    leftButton = (AutoTooltipButton) tupleBuy.third;
    rightButton = (AutoTooltipButton) tupleSell.third;

    leftHeaderLabel = tupleBuy.fourth;
    rightHeaderLabel = tupleSell.fourth;

    bottomHBox = new HBox();
    bottomHBox.setSpacing(20); //30
    bottomHBox.setAlignment(Pos.CENTER);
    VBox.setMargin(bottomHBox, new Insets(-5, 0, 0, 0));
    HBox.setHgrow(tupleBuy.second, Priority.ALWAYS);
    HBox.setHgrow(tupleSell.second, Priority.ALWAYS);
    tupleBuy.second.setUserData(OfferPayload.Direction.BUY.name());
    tupleSell.second.setUserData(OfferPayload.Direction.SELL.name());
    bottomHBox.getChildren().addAll(tupleBuy.second, tupleSell.second);

    root.getChildren().addAll(currencyComboBoxTuple.first, chartPane, bottomHBox);
}
 
Example 7
Source File: GeneratorController.java    From dev-tools with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    uuidAmount.getItems().setAll(1, 2, 3, 5, 10, 20, 50, 100);
    uuidAmount.setValue(1);
    uuidAmountLabel.setPadding(new Insets(5));
    pwdLengthLabel.setPadding(new Insets(5));
    VBox.setMargin(clearButton, new Insets(5, 0, 0, 0));
    pwdLength.setPrefWidth(64);
    pwdLength.setText("16");

    pwdLowChars.setSelected(true);
    pwdDigits.setSelected(true);
}
 
Example 8
Source File: ManagerFragment.java    From mdict-java with GNU General Public License v3.0 5 votes vote down vote up
private Node new_button(String bI, ResourceBundle bundle, EventHandler<ActionEvent> clicker, Insets padding) {
	Button btnTmp = new Button(bundle.getString(bI));
	btnTmp.setId(bI);
	btnTmp.setOnAction(clicker);
	VBox.setMargin(btnTmp, padding);
	return btnTmp;
}
 
Example 9
Source File: Demo.java    From JFX8CustomControls with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) throws Exception {
    VBox pane = new VBox();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.setAlignment(Pos.CENTER);
    pane.setSpacing(10);
    pane.getChildren().addAll(myCtrl, buttonStyleable);
    VBox.setMargin(myCtrl, new Insets(10, 10, 10, 10));

    Scene scene = new Scene(pane);

    stage.setTitle("StyleableProperty");
    stage.setScene(scene);
    stage.show();
}
 
Example 10
Source File: CheckListFormNode.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void addTextArea(String label) {
    CommentBox commentBox = checkList.createCommentBox(label);
    VBox vBox = getVBoxer(commentBox).getVbox(mode.isSelectable(), mode.isEditable());
    HBox.setHgrow(vBox, Priority.ALWAYS);
    VBox.setMargin(vBox, new Insets(5, 10, 3, 5));
    getChildren().add(vBox);
}
 
Example 11
Source File: CheckListFormNode.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public void addCheckListItem(String label) {
    FailureNote failureNote = checkList.createFailureNote(label);
    VBox failureNoteBox = getVBoxer(failureNote).getVbox(mode.isSelectable(), mode.isEditable());
    HBox.setHgrow(failureNoteBox, Priority.ALWAYS);
    VBox.setMargin(failureNoteBox, new Insets(5, 10, 3, 5));
    getChildren().add(failureNoteBox);
}
 
Example 12
Source File: Demo.java    From JFX8CustomControls with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) throws Exception {
    VBox pane = new VBox();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.setAlignment(Pos.CENTER);
    pane.setSpacing(10);
    pane.getChildren().addAll(myCtrl, buttonInteractive);
    VBox.setMargin(myCtrl, new Insets(10, 10, 10, 10));

    Scene scene = new Scene(pane);

    stage.setTitle("CSS PseudoClass");
    stage.setScene(scene);
    stage.show();
}
 
Example 13
Source File: PlaylistsController.java    From MusicPlayer with MIT License 5 votes vote down vote up
void selectPlaylist(Playlist playlist) {
    // Displays the delete button only if the user has not selected one of the default playlists.
    if (playlist instanceof MostPlayedPlaylist || playlist instanceof RecentlyPlayedPlaylist) {
        deleteButton.setVisible(false);
    }

    // Sets the text on the play list title label.
    playlistTitleLabel.setText(playlist.getTitle());

    // Updates the currently selected play list.
    selectedPlaylist = playlist;

    // Retrieves the songs in the selected play list.
    ObservableList<Song> songs = playlist.getSongs();
    
    // Clears the song table.
    tableView.getSelectionModel().clearSelection();
    
    // Populates the song table with the playlist's songs.
    tableView.setItems(songs);

    Label message = new Label(selectedPlaylist.getPlaceholder());
    message.setTextAlignment(TextAlignment.CENTER);

    ImageView image = new ImageView();
    image.setFitHeight(150);
    image.setFitWidth(150);
    image.setImage(new Image(Resources.IMG + "playlistsIcon.png"));

    VBox placeholder = new VBox();
    placeholder.setAlignment(Pos.CENTER);
    placeholder.getChildren().addAll(image, message);
    VBox.setMargin(image, new Insets(0, 0, 50, 0));

    tableView.setPlaceholder(placeholder);
}
 
Example 14
Source File: InfoPopup.java    From charts with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    Font regularFont = Fonts.latoRegular(10);
    Font lightFont   = Fonts.latoLight(10);

    seriesText = new Text("SERIES");
    seriesText.setFill(_textColor);
    seriesText.setFont(regularFont);

    seriesNameText = new Text("-");
    seriesNameText.setFill(_textColor);
    seriesNameText.setFont(lightFont);

    seriesSumText = new Text("SUM");
    seriesSumText.setFill(_textColor);
    seriesSumText.setFont(regularFont);

    seriesValueText = new Text("-");
    seriesValueText.setFill(_textColor);
    seriesValueText.setFont(lightFont);

    itemText = new Text("ITEM");
    itemText.setFill(_textColor);
    itemText.setFont(regularFont);

    itemNameText = new Text("-");
    itemNameText.setFill(_textColor);
    itemNameText.setFont(lightFont);

    valueText = new Text("VALUE");
    valueText.setFill(_textColor);
    valueText.setFont(regularFont);

    itemValueText = new Text("-");
    itemValueText.setFill(_textColor);
    itemValueText.setFont(lightFont);

    line = new Line(0, 0, 0, 56);
    line.setStroke(_textColor);

    VBox vBoxTitles = new VBox(2, seriesText, seriesSumText, itemText, valueText);
    vBoxTitles.setAlignment(Pos.CENTER_LEFT);
    VBox.setMargin(itemText, new Insets(3, 0, 0, 0));

    VBox vBoxValues = new VBox(2, seriesNameText, seriesValueText, itemNameText, itemValueText);
    vBoxValues.setAlignment(Pos.CENTER_RIGHT);
    VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
    HBox.setHgrow(vBoxValues, Priority.ALWAYS);

    hBox = new HBox(5, vBoxTitles, line, vBoxValues);
    hBox.setPrefSize(120, 69);
    hBox.setPadding(new Insets(5));
    hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY)));
    hBox.setMouseTransparent(true);

    getContent().addAll(hBox);
}
 
Example 15
Source File: ListPanelCard.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Given a list of issue events, returns a JavaFX node laying them out properly.
 *
 * @param events
 * @param comments
 * @return
 */
private static Node layoutEvents(GuiElement guiElement,
                                 List<TurboIssueEvent> events, List<Comment> comments) {
    TurboIssue issue = guiElement.getIssue();

    VBox result = new VBox();
    result.setSpacing(3);
    VBox.setMargin(result, new Insets(3, 0, 0, 0));

    // Label update events
    List<TurboIssueEvent> labelUpdateEvents =
            events.stream()
                    .filter(TurboIssueEvent::isLabelUpdateEvent)
                    .collect(Collectors.toList());
    List<Node> labelUpdateEventNodes =
            TurboIssueEvent.createLabelUpdateEventNodes(guiElement, labelUpdateEvents);
    labelUpdateEventNodes.forEach(node -> result.getChildren().add(node));

    // Other events beside label updates
    events.stream()
            .filter(e -> !e.isLabelUpdateEvent())
            .map(e -> e.display(guiElement, issue))
            .forEach(e -> result.getChildren().add(e));

    // Comments
    if (!comments.isEmpty()) {
        String names = comments.stream()
                .map(comment -> comment.getUser().getLogin())
                .distinct()
                .collect(Collectors.joining(", "));
        HBox commentDisplay = new HBox();
        commentDisplay.getChildren().addAll(
                TurboIssueEvent.octicon(TurboIssueEvent.OCTICON_QUOTE),
                new javafx.scene.control.Label(
                        String.format("%d comments since, involving %s.", comments.size(), names))
        );
        result.getChildren().add(commentDisplay);
    }

    return result;
}
 
Example 16
Source File: InfoPopup.java    From charts with Apache License 2.0 4 votes vote down vote up
public void update(final SelectionEvent EVENT) {
    ChartItemSeries series = EVENT.getSeries();
    ChartItem       item   = EVENT.getItem();
    if (null == series && null == item) {
        this.setOpacity(0);
    } else {
        this.setOpacity(1);
    }
    if (null == series) {
        Helper.enableNode(seriesText, false);
        Helper.enableNode(seriesSumText, false);
        Helper.enableNode(seriesNameText, false);
        Helper.enableNode(seriesValueText, false);
        setTo2Rows();
    } else {
        seriesNameText.setText(EVENT.getSeries().getName());
        seriesValueText.setText(String.format(Locale.US, formatString, EVENT.getSeries().getSumOfAllItems()));
        Helper.enableNode(seriesText, true);
        Helper.enableNode(seriesSumText, true);
        Helper.enableNode(seriesNameText, true);
        Helper.enableNode(seriesValueText, true);
        setTo4Rows();
    }
    if (null == item) {
        Helper.enableNode(itemText, false);
        Helper.enableNode(valueText, false);
        Helper.enableNode(itemNameText, false);
        Helper.enableNode(itemValueText, false);
        VBox.setMargin(itemNameText, new Insets(0, 0, 0, 0));
        setTo2Rows();
    } else {
        itemNameText.setText(null == EVENT.getItem() ? "-" : EVENT.getItem().getName());
        itemValueText.setText(null == EVENT.getItem() ? "-" : String.format(Locale.US, formatString, EVENT.getItem().getValue()));
        Helper.enableNode(itemText, true);
        Helper.enableNode(valueText, true);
        Helper.enableNode(itemNameText, true);
        Helper.enableNode(itemValueText, true);
        VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
        if (null == series) {
            VBox.setMargin(itemText, new Insets(0, 0, 0, 0));
            VBox.setMargin(itemNameText, new Insets(0, 0, 0, 0));
        } else {
            VBox.setMargin(itemText, new Insets(3, 0, 0, 0));
            VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
            setTo4Rows();
        }
    }
}
 
Example 17
Source File: AddonFileMinimalView.java    From CMPDL with MIT License 4 votes vote down vote up
public AddonFileMinimalView() {
    fileName.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, 16));
    fileType.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, Font.getDefault().getSize()));
    root.getChildren().addAll(fileName, gameVersion, fileType);
    VBox.setMargin(fileType, new Insets(0, 0, 0, 2));
}
 
Example 18
Source File: EpidemicReportsSettingsController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
protected void makeLocationsColors() {
    try {
        colorRects.clear();
        locationColorsBox.getChildren().clear();
        List<GeographyCode> locations = chartController.chartLocations;
        if (locations == null || locationColors == null) {
            return;
        }
        Collections.sort(locations, (GeographyCode p1, GeographyCode p2)
                -> p1.getFullName().compareTo(p2.getFullName()));
        for (int i = 0; i < locations.size(); i++) {
            GeographyCode location = locations.get(i);
            String name = location.getFullName();
            String color = locationColors.get(name);
            Label label = new Label(name);
            Rectangle rect = new Rectangle();
            rect.setWidth(15);
            rect.setHeight(15);
            Color c = Color.web(color);
            rect.setFill(c);
            FxmlControl.setTooltip(rect, new Tooltip(FxmlColor.colorNameDisplay(c)));
            rect.setUserData(name);
            colorRects.add(rect);

            Button button = new Button();
            ImageView image = new ImageView(ControlStyle.getIcon("iconPalette.png"));
            image.setFitWidth(AppVariables.iconSize);
            image.setFitHeight(AppVariables.iconSize);
            button.setGraphic(image);
            button.setOnAction((ActionEvent event) -> {
                showPalette(button, message("Settings") + " - " + name);
            });
            button.setUserData(i);
            VBox.setMargin(button, new Insets(0, 0, 0, 15));
            FxmlControl.setTooltip(button, message("Palette"));

            HBox line = new HBox();
            line.setAlignment(Pos.CENTER_LEFT);
            line.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            line.setSpacing(5);
            VBox.setVgrow(line, Priority.ALWAYS);
            HBox.setHgrow(line, Priority.ALWAYS);
            line.getChildren().addAll(label, rect, button);

            locationColorsBox.getChildren().add(line);
        }
    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example 19
Source File: DotRecordBasedJavaFxNode.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void setMargin(Node text, Insets insets) {
	VBox.setMargin(text, insets);
}
 
Example 20
Source File: TextFlowApp.java    From oim-fx with MIT License 2 votes vote down vote up
public Parent createContent() {

		String family = "Helvetica";

		double size = 20;

		// Simple example

		textFlow = new TextFlow();
		
		textHello = new Text("Hello ");

		textHello.setFont(Font.font(family, size));
		textBold = new Text("Bold");
		textBold.setFont(Font.font(family, FontWeight.BOLD, size));
		textWorld = new Text(" World");
		textWorld.setFont(Font.font(family, FontPosture.ITALIC, size));
		textFlow.getChildren().addAll(textHello, textBold, textWorld);

		// Example with embedded objects

		TextFlow textFlowEmbedObj = new TextFlow();
		Text textEO1 = new Text("Lets have ");
		textEO1.setFont(Font.font(family, size));
		Text textEO2 = new Text("embedded objects: a Rectangle ");

		textEO2.setFont(Font.font(family, FontWeight.BOLD, size));

		Rectangle rect = new Rectangle(80, 60);

		rect.setFill(null);
		rect.setStroke(Color.GREEN);
		rect.setStrokeWidth(5);
		Text textEO3 = new Text(", then a button ");

		Button button = new Button("click me");
		Text textEO4 = new Text(", and finally an image ");

		ImageView imageView = new ImageView(image);
		Text textEO5 = new Text(".");

		textEO5.setFont(Font.font(family, size));

		textFlowEmbedObj.getChildren().addAll(textEO1, textEO2, rect, textEO3, button, textEO4, imageView, textEO5);

		VBox vbox = new VBox(18);

		VBox.setMargin(textFlow, new Insets(5, 5, 0, 5));

		VBox.setMargin(textFlowEmbedObj, new Insets(0, 5, 5, 5));

		vbox.getChildren().addAll(textFlow, textFlowEmbedObj);
		return vbox;

	}