Example usage for javafx.scene.layout HBox setHgrow

List of usage examples for javafx.scene.layout HBox setHgrow

Introduction

In this page you can find the example usage for javafx.scene.layout HBox setHgrow.

Prototype

public static void setHgrow(Node child, Priority value) 

Source Link

Document

Sets the horizontal grow priority for the child when contained by an hbox.

Usage

From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java

@Override
protected BatchUpdateDialog createDialog() {

    ObservableList<UpdateFileNamesFromTagsItem> items = FXCollections.observableArrayList(
            this.getOtherFiles().stream().map(UpdateFileNamesFromTagsItem::new).collect(Collectors.toList()));
    StringProperty patternFieldProperty = new SimpleStringProperty();

    List<String> patternItems = Arrays.asList("${track} ${title}");
    ComboBox<String> patternBox = new ComboBox<>(FXCollections.observableArrayList(patternItems));
    patternBox.setEditable(true);//from  w ww .  ja  v a 2 s.  com
    patternBox.setMaxWidth(Double.MAX_VALUE);
    Bindings.bindBidirectional(patternFieldProperty, patternBox.editorProperty().get().textProperty());
    HBox.setHgrow(patternBox, Priority.ALWAYS);

    Button executeButton = new Button(this.getLocalization().executeRename(),
            new ImageView(new Image(UpdateFileNamesFromTagsActionEventHandler.class.getClassLoader()
                    .getResourceAsStream("icons/16/save.png"))));
    executeButton.setDisable(true);
    patternFieldProperty
            .addListener((o, oldValue, newValue) -> executeButton.setDisable(newValue.length() <= 0));

    HBox patternFieldPane = new HBox(10, patternBox, executeButton);
    patternFieldPane.setPadding(new Insets(5, 5, 5, 5));

    TitledPane patternFieldTitlePane = new TitledPane(this.getLocalization().fileNamePattern(),
            patternFieldPane);
    patternFieldTitlePane.setCollapsible(false);

    TableView<?> newFileNamesPane = this.createNewFileNamesPane(items);
    newFileNamesPane.setPrefHeight(400);
    VBox.setVgrow(newFileNamesPane, Priority.ALWAYS);

    VBox actionPane = new VBox(10, patternFieldTitlePane, newFileNamesPane);

    // Create the dialog and finish
    BatchUpdateDialog dialog = new BatchUpdateDialog();
    dialog.setDialogPrefWidth(800);
    dialog.setDialogTitle(this.getLocalization().updateFileNames());
    dialog.setActionPane(actionPane);
    dialog.setLegendPane(this.createLegendPane());

    // Add listeners
    this.getOtherFiles().addListener(
            new WeakListChangeListener<>((Change<? extends TaggableFile> change) -> items.setAll(change
                    .getList().stream().map(UpdateFileNamesFromTagsItem::new).collect(Collectors.toList()))));
    patternFieldProperty.addListener((o, oldValue, newValue) -> this.computeNewFileNames(items, newValue));
    executeButton.setOnAction(event -> {
        this.updateNewFileNames(items);
        ((Stage) executeButton.getScene().getWindow()).close();
    });

    return dialog;

}

From source file:com.panemu.tiwulfx.form.BaseControl.java

public BaseControl(String propertyName, E control) {
    this.inputControl = control;
    this.propertyName = propertyName;
    HBox.setHgrow(control, Priority.ALWAYS);
    setAlignment(Pos.CENTER_LEFT);/*from   w w  w  . j  a  v a 2  s  .  co  m*/
    control.setMaxWidth(Double.MAX_VALUE);
    control.setMinHeight(USE_PREF_SIZE);
    getChildren().add(control);
    getChildren().add(imagePlaceHolder);

    required.addListener(imageListener);
    valid.addListener(imageListener);

    this.getStyleClass().add("form-control");
    value = new SimpleObjectProperty<>();
    bindValuePropertyWithControl(control);
    bindEditablePropertyWithControl(control);

    addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.getEventType() == MouseEvent.MOUSE_MOVED && !isValid() && !getPopup().isShowing()) {
                Point2D p = BaseControl.this.localToScene(0.0, 0.0);
                getPopup().show(BaseControl.this, p.getX() + getScene().getX() + getScene().getWindow().getX(),
                        p.getY() + getScene().getY() + getScene().getWindow().getY()
                                + getInputComponent().getHeight() - 1);
            } else if (event.getEventType() == MouseEvent.MOUSE_EXITED && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
    getInputComponent().addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent t) {
            if (!isValid() && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
}

From source file:com.panemu.tiwulfx.form.BaseListControl.java

public BaseListControl(String propertyName, E control) {
    this.inputControl = control;
    this.propertyName = propertyName;
    HBox.setHgrow(control, Priority.ALWAYS);
    setAlignment(Pos.CENTER_LEFT);// w w w .  ja v a2  s  .  c o  m
    control.setMaxWidth(Double.MAX_VALUE);
    control.setMinHeight(USE_PREF_SIZE);
    getChildren().add(control);
    getChildren().add(imagePlaceHolder);

    required.addListener(imageListener);
    valid.addListener(imageListener);

    this.getStyleClass().add("form-control");
    value = new SimpleListProperty<>();
    bindValuePropertyWithControl(control);
    bindEditablePropertyWithControl(control);

    addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.getEventType() == MouseEvent.MOUSE_MOVED && !isValid() && !getPopup().isShowing()) {
                Point2D p = BaseListControl.this.localToScene(0.0, 0.0);
                getPopup().show(BaseListControl.this,
                        p.getX() + getScene().getX() + getScene().getWindow().getX(),
                        p.getY() + getScene().getY() + getScene().getWindow().getY()
                                + getInputComponent().getHeight() - 1);
            } else if (event.getEventType() == MouseEvent.MOUSE_EXITED && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
    getInputComponent().addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent t) {
            if (!isValid() && getPopup().isShowing()) {
                getPopup().hide();
            }
        }
    });
}

From source file:com.github.drbookings.ui.controller.BookingDetailsController.java

private static void addName(final HBox content, final BookingBean be) {
    final Label label = new Label(be.getGuest().getName() + "\n" + be.getBookingOrigin().getName());
    label.setWrapText(true);/*from   w  w w .  j a  v  a 2 s .  co  m*/
    content.getChildren().add(label);
    HBox.setHgrow(label, Priority.ALWAYS);

}

From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.HighlightsViewControllerImpl.java

@FXML
private void initialize() {
    tagImageTiles.addAll(Arrays.asList(tag1, tag2, tag3, tag4, tag5));

    wikipediaInfoPane = new WikipediaInfoPane(wikipediaService);
    HBox.setHgrow(wikipediaInfoPane, Priority.ALWAYS);
    wikipediaInfoPaneContainer.getChildren().addAll(wikipediaInfoPane, wikipediaPlaceholder);

    wikipediaPlaceholder.setGlyphSize(80);
    wikipediaInfoPaneContainer.setAlignment(Pos.CENTER);
    wikipediaPlaceholder.getStyleClass().addAll("wikipedia-placeholder");
    wikipediaInfoPane.managedProperty().bind(wikipediaInfoPane.visibleProperty());
    wikipediaPlaceholder.visibleProperty().bind(wikipediaInfoPane.visibleProperty().not());
    wikipediaInfoPane.setVisible(false);

    journeyPlaceList.setOnJourneySelected(this::handleJourneySelected);
    journeyPlaceList.setOnPlaceSelected(this::handlePlaceSelected);
    journeyPlaceList.setOnAllPlacesSelected(this::handleAllPlacesSelected);

    // give each row and each column in the grid the same size
    ColumnConstraints column1 = new ColumnConstraints();
    column1.setPercentWidth(25);//from   w w  w .ja v a 2s  . c o m
    ColumnConstraints column2 = new ColumnConstraints();
    column2.setPercentWidth(25);
    ColumnConstraints column3 = new ColumnConstraints();
    column3.setPercentWidth(25);
    ColumnConstraints column4 = new ColumnConstraints();
    column4.setPercentWidth(25);
    gridPane.getColumnConstraints().addAll(column1, column2, column3, column4);

    RowConstraints row1 = new RowConstraints();
    row1.setPercentHeight(33);
    RowConstraints row2 = new RowConstraints();
    row2.setPercentHeight(33);
    RowConstraints row3 = new RowConstraints();
    row3.setPercentHeight(33);
    gridPane.getRowConstraints().addAll(row1, row2, row3);

    clusterService.subscribeJourneyChanged((journey) -> scheduler
            .schedule(() -> Platform.runLater(this::reloadJourneys), 2, TimeUnit.SECONDS));

    clusterService.subscribePlaceChanged(
            (place) -> scheduler.schedule(() -> Platform.runLater(this::reloadJourneys), 2, TimeUnit.SECONDS));

    photoService.subscribeCreate(addBuffer::add);

    reloadJourneys();
}

From source file:com.github.drbookings.ui.controller.BookingDetailsController.java

private static void addRow0(final Pane content, final BookingBean be) {
    final HBox box = new HBox();
    final HBox boxName = new HBox();
    final HBox boxDates = new HBox();
    final HBox boxNights = new HBox();
    box.setAlignment(Pos.CENTER);/*from w  w w.  j  a v a  2s  .  com*/
    boxName.getStyleClass().add("first-line");
    boxDates.getStyleClass().add("first-line");
    boxNights.getStyleClass().add("first-line");
    boxName.setPadding(boxPadding);
    boxDates.setPadding(boxPadding);
    boxNights.setPadding(boxPadding);
    boxName.setAlignment(Pos.CENTER);
    boxDates.setAlignment(Pos.CENTER);
    boxNights.setAlignment(Pos.CENTER);
    HBox.setHgrow(boxName, Priority.ALWAYS);
    HBox.setHgrow(boxDates, Priority.ALWAYS);
    HBox.setHgrow(boxNights, Priority.ALWAYS);
    addName(boxName, be);
    // box.getChildren().add(new Separator(Orientation.VERTICAL));
    addDates(boxDates, be);
    // box.getChildren().add(new Separator(Orientation.VERTICAL));
    addNights(boxNights, be);
    box.getChildren().addAll(boxName, boxDates, boxNights);
    box.getStyleClass().add(Styles.getBackgroundStyleSource(be.getBookingOrigin().getName()));
    content.getChildren().add(box);

}

From source file:Main.java

HBox getButtons() {
    Region spring = new Region();
    HBox.setHgrow(spring, Priority.ALWAYS);
    HBox buttonBar = new HBox(5);
    cancelButton.setCancelButton(true);//ww  w .ja v  a  2  s .c om
    finishButton.setDefaultButton(true);
    buttonBar.getChildren().addAll(spring, priorButton, nextButton, cancelButton, finishButton);
    return buttonBar;
}

From source file:webviewsample.Main.java

private Node createSpacer() {
    Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    return spacer;
}

From source file:MediaControl.java

public MediaControl(final MediaPlayer mp) {
    this.mp = mp;
    setStyle("-fx-background-color: #bfc2c7;");
    mediaView = new MediaView(mp);
    Pane mvPane = new Pane() {
    };/*  w  ww .ja  v a 2s .co m*/
    mvPane.getChildren().add(mediaView);
    mvPane.setStyle("-fx-background-color: black;");
    setCenter(mvPane);
    mediaBar = new HBox();
    mediaBar.setAlignment(Pos.CENTER);
    mediaBar.setPadding(new Insets(5, 10, 5, 10));
    BorderPane.setAlignment(mediaBar, Pos.CENTER);

    final Button playButton = new Button(">");

    playButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Status status = mp.getStatus();

            if (status == Status.UNKNOWN || status == Status.HALTED) {
                // don't do anything in these states
                return;
            }

            if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) {
                // rewind the movie if we're sitting at the end
                if (atEndOfMedia) {
                    mp.seek(mp.getStartTime());
                    atEndOfMedia = false;
                }
                mp.play();
            } else {
                mp.pause();
            }
        }
    });
    mp.currentTimeProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            updateValues();
        }
    });

    mp.setOnPlaying(new Runnable() {
        public void run() {
            if (stopRequested) {
                mp.pause();
                stopRequested = false;
            } else {
                playButton.setText("||");
            }
        }
    });

    mp.setOnPaused(new Runnable() {
        public void run() {
            System.out.println("onPaused");
            playButton.setText(">");
        }
    });

    mp.setOnReady(new Runnable() {
        public void run() {
            duration = mp.getMedia().getDuration();
            updateValues();
        }
    });

    mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
    mp.setOnEndOfMedia(new Runnable() {
        public void run() {
            if (!repeat) {
                playButton.setText(">");
                stopRequested = true;
                atEndOfMedia = true;
            }
        }
    });
    mediaBar.getChildren().add(playButton);
    // Add spacer
    Label spacer = new Label("   ");
    mediaBar.getChildren().add(spacer);

    // Add Time label
    Label timeLabel = new Label("Time: ");
    mediaBar.getChildren().add(timeLabel);

    // Add time slider
    timeSlider = new Slider();
    HBox.setHgrow(timeSlider, Priority.ALWAYS);
    timeSlider.setMinWidth(50);
    timeSlider.setMaxWidth(Double.MAX_VALUE);

    timeSlider.valueProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (timeSlider.isValueChanging()) {
                // multiply duration by percentage calculated by slider position
                mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
            }
        }
    });

    mediaBar.getChildren().add(timeSlider);

    // Add Play label
    playTime = new Label();
    playTime.setPrefWidth(130);
    playTime.setMinWidth(50);
    mediaBar.getChildren().add(playTime);

    // Add the volume label
    Label volumeLabel = new Label("Vol: ");
    mediaBar.getChildren().add(volumeLabel);

    // Add Volume slider
    volumeSlider = new Slider();
    volumeSlider.setPrefWidth(70);
    volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
    volumeSlider.setMinWidth(30);
    volumeSlider.valueProperty().addListener(new InvalidationListener() {
        public void invalidated(Observable ov) {
            if (volumeSlider.isValueChanging()) {
                mp.setVolume(volumeSlider.getValue() / 100.0);
            }
        }
    });
    mediaBar.getChildren().add(volumeSlider);
    setBottom(mediaBar);
}

From source file:Main.java

private void addStackPane(HBox hb) {

    StackPane stack = new StackPane();
    Rectangle helpIcon = new Rectangle(30.0, 25.0);
    helpIcon.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE,
            new Stop[] { new Stop(0, Color.web("#4977A3")), new Stop(0.5, Color.web("#B0C6DA")),
                    new Stop(1, Color.web("#9CB6CF")), }));
    helpIcon.setStroke(Color.web("#D0E6FA"));
    helpIcon.setArcHeight(3.5);/*from  w  ww  . j av  a2s  .  c om*/
    helpIcon.setArcWidth(3.5);

    Text helpText = new Text("?");
    helpText.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
    helpText.setFill(Color.WHITE);
    helpText.setStroke(Color.web("#7080A0"));

    stack.getChildren().addAll(helpIcon, helpText);
    stack.setAlignment(Pos.CENTER_RIGHT);
    // Add offset to right for question mark to compensate for RIGHT 
    // alignment of all nodes
    StackPane.setMargin(helpText, new Insets(0, 10, 0, 0));

    hb.getChildren().add(stack);
    HBox.setHgrow(stack, Priority.ALWAYS);

}