Example usage for javafx.scene.layout HBox setAlignment

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

Introduction

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

Prototype

public final void setAlignment(Pos value) 

Source Link

Usage

From source file:org.jacp.demo.components.ContactAddDialog.java

private void createAddContactDialog() {
    final VBox box = new VBox();
    box.getStyleClass().add("jacp-option-pane");
    box.setMaxSize(300, Region.USE_PREF_SIZE);
    // the title//from ww w  .j a v  a2s.c om
    final Label title = new Label("Add new category");
    title.setId(GlobalConstants.CSSConstants.ID_JACP_CUSTOM_TITLE);
    VBox.setMargin(title, new Insets(2, 2, 10, 2));

    final HBox hboxInput = new HBox();
    final Label nameLabel = new Label("category name:");
    HBox.setMargin(nameLabel, new Insets(2));
    final TextField nameInput = new TextField();
    HBox.setMargin(nameInput, new Insets(0, 0, 0, 5));
    HBox.setHgrow(nameInput, Priority.ALWAYS);
    hboxInput.getChildren().addAll(nameLabel, nameInput);

    final HBox hboxButtons = new HBox();
    hboxButtons.setAlignment(Pos.CENTER_RIGHT);
    final Button ok = new Button("OK");
    HBox.setMargin(ok, new Insets(6, 5, 4, 2));
    final Button cancel = new Button("Cancel");
    HBox.setMargin(cancel, new Insets(6, 2, 4, 5));
    cancel.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(final ActionEvent arg0) {
            JACPModalDialog.getInstance().hideModalDialog();
        }
    });

    ok.setDefaultButton(true);
    ok.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent actionEvent) {
            final String catName = nameInput.getText();
            if (catName != null && StringUtils.hasText(catName)) {
                // contacts
                final Contact contact = new Contact();
                contact.setFirstName(catName);
                parent.getContext().send(contact);
                JACPModalDialog.getInstance().hideModalDialog();
            }
        }
    });

    hboxButtons.getChildren().addAll(ok, cancel);
    box.getChildren().addAll(title, hboxInput, hboxButtons);
    JACPModalDialog.getInstance().showModalDialog(box);
}

From source file:com.thomaskuenneth.openweathermapweather.BasicView.java

public BasicView(String name) {
    super(name);/*from   w  w  w .ja  v  a 2 s  .  co  m*/
    bundle = ResourceBundle.getBundle("com.thomaskuenneth.openweathermapweather.strings");
    city = new TextField();
    city.setFloatText(bundle.getString("hint"));
    Button show = new Button(bundle.getString("anzeigen"));
    image = new ImageView();
    temperatur = new Text();
    beschreibung = new Text();
    VBox texts = new VBox(temperatur, beschreibung);
    HBox hb1 = new HBox(10, image, texts);
    hb1.setPadding(new Insets(10, 0, 0, 0));
    hb1.setAlignment(Pos.TOP_LEFT);
    show.setOnAction(e -> doIt());
    VBox controls = new VBox(10, city, show, hb1);
    controls.setPadding(new Insets(14, 14, 14, 14));
    controls.setAlignment(Pos.TOP_LEFT);
    setCenter(controls);
}

From source file:com.bdb.weather.display.current.Thermometer.java

/**
 * Constructor.//from   www .  j  av a  2s . c o m
 * 
 * @param title The title to display in the containing panel
 * @param min The minimum value for the thermometer scale
 * @param max The maximum value for the thermometer scale
 */
public Thermometer(String title, Temperature min, Temperature max) {
    this.setPrefSize(150.0, 200.0);
    minValue = min;
    maxValue = max;
    unitProperty.setValue(Temperature.getDefaultUnit());
    setUnits(unitProperty.getValue());
    ChartViewer chartViewer = createChartElements();
    this.setCenter(chartViewer);
    HBox p = new HBox();
    p.setAlignment(Pos.CENTER);
    Label label = new Label("High: ");
    label.setStyle("-fx-font-weight: bold");
    p.getChildren().addAll(label, highLabel);
    this.setTop(p);
    p = new HBox();
    p.setAlignment(Pos.CENTER);
    label = new Label("Low: ");
    label.setStyle("-fx-font-weight: bold");
    p.getChildren().addAll(label, lowLabel);
    this.setBottom(p);

    unitProperty.addListener((ObservableValue<? extends Temperature.Unit> observable, Temperature.Unit oldValue,
            Temperature.Unit newValue) -> {
        setUnits(newValue);
    });
}

From source file:org.pdfsam.ui.io.PdfDestinationPane.java

public PdfDestinationPane(BrowsableField destination, String ownerModule) {
    super(destination);
    this.ownerModule = defaultString(ownerModule);
    version = new PdfVersionCombo(ownerModule);
    compress = new PdfVersionConstrainedCheckBox(PdfVersion.VERSION_1_5, ownerModule);
    compress.setText(DefaultI18nContext.getInstance().i18n("Compress output file/files"));
    HBox versionPane = new HBox(2,
            new Label(DefaultI18nContext.getInstance().i18n("Output document pdf version:")), version);
    versionPane.setAlignment(Pos.BOTTOM_LEFT);
    versionPane.getStyleClass().addAll(Style.VITEM.css());
    getHChildren().add(compress);//from ww w.  ja v a 2 s. c om
    getChildren().addAll(versionPane);
    eventStudio().addAnnotatedListeners(this);
}

From source file:org.pdfsam.ui.selection.single.SingleSelectionPane.java

public SingleSelectionPane(String ownerModule) {
    super(5);//from   www .j  av  a  2  s . c o  m
    this.ownerModule = defaultString(ownerModule);
    field.enforceValidation(true, false);
    field.getTextField().setPromptText(
            DefaultI18nContext.getInstance().i18n("Select or drag and drop the PDF you want to split"));
    encryptionIndicator = new LoadingStatusIndicator(this, this.ownerModule);
    field.setGraphic(encryptionIndicator);
    HBox.setMargin(encryptionIndicator, new Insets(0, 0, 0, 2));
    HBox topRow = new HBox(5, field);
    HBox.setHgrow(field, Priority.ALWAYS);
    topRow.setAlignment(Pos.CENTER_LEFT);
    getChildren().addAll(topRow, pages);
    field.getTextField().setEditable(false);
    field.getTextField().validProperty().addListener((o, oldVal, newVal) -> {
        if (newVal == ValidationState.VALID) {
            if (descriptor != null) {
                descriptor.invalidate();
            }
            PdfLoadRequestEvent loadEvent = new PdfLoadRequestEvent(getOwnerModule());
            descriptor = PdfDocumentDescriptor
                    .newDescriptorNoPassword(new File(field.getTextField().getText()));
            descriptor.loadedProperty().addListener(new WeakChangeListener<>(onDescriptorLoaded));
            field.getTextField().getContextMenu().getItems().forEach(i -> i.setDisable(false));
            loadEvent.add(descriptor);
            eventStudio().broadcast(loadEvent);
        }
    });
    initContextMenu();
}

From source file:net.thirdy.blackmarket.controls.ModSelectionPane.java

public ModSelectionPane() {
    setHgap(5.0);//from  w ww  . j ava  2  s  .co  m
    setMaxHeight(Double.MAX_VALUE);
    setMinHeight(560);
    setAlignment(Pos.CENTER);
    setupModListView();
    accept(Collections.emptyList());
    setupModMappingTable();
    setupFilterTextField();
    tfMinShouldMatch = new DoubleTextField("Minimum number of OR modifiers to match");
    tfMinShouldMatch.setMinWidth(350);

    Button add = addButton();
    add.setPrefWidth(150);
    HBox hBox = new HBox(5, new Label("Filter: "), filterField, add);
    hBox.setAlignment(Pos.CENTER);

    VBox.setVgrow(modMappingTable, Priority.ALWAYS);
    VBox left = new VBox(10, hBox, modMappingTable);
    VBox.setVgrow(modsListView, Priority.ALWAYS);
    Label modifiersLbl = new Label("Modifiers");
    modifiersLbl.setFont(Font.font("Verdana", FontWeight.MEDIUM, 14));
    modifiersLbl.setPadding(new Insets(4));
    HBox minShouldMatchHBox = new HBox(3, new Label("Minimum OR Matches:"), tfMinShouldMatch);
    minShouldMatchHBox.setAlignment(Pos.CENTER);
    VBox right = new VBox(3, new StackPane(modifiersLbl), minShouldMatchHBox, modsListView);

    setupGridPaneColumns();

    GridPane.setVgrow(left, Priority.ALWAYS);
    GridPane.setVgrow(right, Priority.ALWAYS);
    add(left, 0, 0);
    add(right, 1, 0);
}

From source file:guipart.AddMessageUploadFile.java

private void setScene(Stage window) {
    fileNames = new ArrayList<File>();
    fileList = new ListView<String>();
    files = FXCollections.observableArrayList();
    fileList.setItems(files);/*ww w. j av a2 s .  c  o m*/

    fileList.setTranslateY(-50);
    fileList.setMaxWidth(300);
    fileList.setMinHeight(150);

    Label addMessagesLabel = new Label("Add messages");
    Label loadedMessagesLabel = new Label("Loaded messages:");

    Label imageLabel2 = new Label();
    Image image2 = new Image(getClass().getResourceAsStream("/resources/gui/labelme_logo.png"));
    imageLabel2.setGraphic(new ImageView(image2));
    imageLabel2.setPrefSize(200, 200);
    HBox imageBox2 = new HBox();
    imageBox2.setAlignment(Pos.CENTER);
    imageBox2.setPadding(new Insets(20, 20, 20, 20));
    imageBox2.getChildren().add(imageLabel2);

    acceptButton = new Button("Accept All");
    browseButton = new Button("Browse");
    finishButton = new Button("Finish");
    previousButton = new Button("Previous");
    cancelButton = new Button("X");
    backButton = new Button("Back");
    pathField.setMinWidth(200);
    textCategory = new Label();

    addMessagesLabel.setFont(Font.font("Arial", FontWeight.BOLD, 28));

    HBox hBox = new HBox();
    hBox.setSpacing(20);
    hBox.getChildren().addAll(browseButton, pathField, acceptButton);
    hBox.setAlignment(Pos.CENTER);

    VBox layout = new VBox();
    layout.setSpacing(30);

    VBox filesPlaceholder = new VBox();
    filesPlaceholder.setSpacing(10);

    backButton.setTranslateY(-50);

    browseButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            //TODO: add more extensionFilters
            File currDir = new File(".");
            fileChooser.setInitialDirectory(currDir);
            fileChooser.getExtensionFilters().addAll((new FileChooser.ExtensionFilter("Text Files", "*.txt")));
            File file = fileChooser.showOpenDialog(window);

            if (file != null) {
                pathField.setText(file.getName());
                fileNames.add(file);
                files.add(file.getName());
            }
        }

    });

    fileList.setOnMouseClicked(e -> {
        //System.out.println(fileList.getSelectionModel().getSelectedItem());
        files.remove(fileList.getSelectionModel().getSelectedItem());
        for (File file : fileNames) {
            if (file.getName().equals(fileList.getSelectionModel().getSelectedItem())) {
                fileNames.remove(file);
                break;
            }
        }
    });

    acceptButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            if (!fileNames.isEmpty()) {
                Categorize categorize = new Categorize();
                categorize.trainModel();

                int size = files.size();

                for (int i = 0; i < size; i++) {
                    String fileName = files.get(i);
                    for (File file : fileNames) {
                        if (file.getName().equals(fileName)) {
                            try {
                                files.add(fileName + "      "
                                        + categorize.getCategory(FileUtils.readFileToString(file, "UTF-8")));
                            } catch (IOException ex) {
                                Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null,
                                        ex);
                            }
                        }
                    }

                }

                int i = 0;
                while (i < size) {
                    files.remove(0);
                    i++;
                }
                /*
                try {
                textCategory.setText("The text category is: " + categorize.getCategory(FileUtils.readFileToString(fileNames.get(fileNames.size() - 1), "UTF-8")));
                } catch (IOException ex) {
                Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null, ex);
                }*/
            }
            /*
            if (pathField.getText() != null) {
            int index = pathField.getText().lastIndexOf("\\");
                    
            Label messageLabel = new Label(pathField.getText().substring(index + 1));
            messageLabel.setMinWidth(200);
            messageLabel.setMinHeight(25);
            messageLabel.setStyle("-fx-fill: orange;\n"
                    + "-fx-border-color: blue;\n"
                    + "-fx-border-width: 3;\n");
            if (filesPlaceholder.getChildren().size() != 0) {
                layout.getChildren().remove(layout.getChildren().size() - 1);
            }
                    
            filesPlaceholder.getChildren().addAll(messageLabel);
            filesPlaceholder.setAlignment(Pos.CENTER);
            filesPlaceholder.setPadding(new Insets(0, 0, 0, 50));
                    
            layout.getChildren().add(filesPlaceholder);
            }*/
        }
    });

    backButton.setOnAction(e -> {
        window.setScene(mainPage.mainPageScene);

    });

    layout.getChildren().addAll(imageLabel2, addMessagesLabel, hBox, textCategory, fileList, backButton);
    layout.setStyle("-fx-background-color: white");
    layout.setAlignment(Pos.TOP_CENTER);
    layout.setStyle("-fx-background-color: #B8EDFF;");
    scene = new Scene(layout, 900, 600);
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    HBox hbox = new HBox();
    Button button1 = new Button("Add");
    Button button2 = new Button("Remove");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);//from   w  w  w . j  ava 2s . c  o m

    hbox.setAlignment(Pos.BASELINE_CENTER);

    root.getChildren().add(hbox);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:calendarioSeries.vistas.NewSerieController.java

@FXML
public void handleOk() {
    String tituloAux = titulo.getText().replaceAll(" ", "+").toLowerCase();
    String toJson = readUrl(BASE + tituloAux + "&type=series" + "&r=json");
    resultados.getChildren().clear();/*from w w w .j a  va 2 s  .c  o m*/
    try {
        JSONObject busqueda = new JSONObject(toJson);
        if (busqueda.getString("Response").equals("True")) {
            JSONArray res = busqueda.getJSONArray("Search");
            resultados.setPrefRows(res.length());
            for (int i = 0; i < res.length(); i++) {
                JSONObject resActual = new JSONObject(res.get(i).toString());
                HBox resultadoActual = new HBox(50);
                resultadoActual.setMaxWidth(Double.MAX_VALUE);
                resultadoActual.setAlignment(Pos.CENTER_LEFT);
                ImageView posterActual = new ImageView();

                try {
                    Image image = new Image(resActual.getString("Poster"));
                    posterActual.setImage(image);
                    posterActual.setFitHeight(240);
                    posterActual.setFitWidth(180);
                    posterActual.setPreserveRatio(false);
                    resultadoActual.getChildren().add(posterActual);
                } catch (IllegalArgumentException e) {
                    //                        System.out.println("Bad url");
                    Image image = new Image(
                            MainApp.class.getResource("resources/no-image.png").toExternalForm());
                    posterActual.setImage(image);
                    posterActual.setFitHeight(240);
                    posterActual.setFitWidth(180);
                    posterActual.setPreserveRatio(false);
                    resultadoActual.getChildren().add(posterActual);
                }

                String details;
                String nomSerie = new String(resActual.getString("Title").getBytes(), "UTF-8");
                String anoSerie = new String(resActual.getString("Year").getBytes(), "UTF-8");
                if (nomSerie.length() > 15) {
                    details = "%-12.12s...\t\t Ao: %-10s";
                } else {
                    details = "%-12s\t\t Ao: %-10s";
                }
                details = String.format(details, nomSerie, anoSerie);
                Label elemento = new Label(details);
                elemento.setMaxWidth(Double.MAX_VALUE);
                elemento.setMaxHeight(Double.MAX_VALUE);
                resultadoActual.getChildren().add(elemento);

                posterActual.setId(resActual.getString("imdbID"));
                posterActual.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        ImageView clickedButton = (ImageView) event.getSource();
                        Stage stage = (Stage) clickedButton.getScene().getWindow();
                        Task task = new Task() {
                            @Override
                            protected Object call() throws Exception {
                                mainController.mainApp.scene.setCursor(Cursor.WAIT);
                                Serie toAdd = new Serie(clickedButton.getId());
                                boolean possible = true;
                                for (Serie serie : mainController.getSeries()) {
                                    if (serie.equals(toAdd))
                                        possible = false;
                                }
                                if (possible)
                                    mainController.getSeries().add(toAdd);

                                try {
                                    mainController.populateImagenes();
                                    mainController.showDetallesMes(mainController.getMesActual());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                } finally {
                                    mainController.mainApp.scene.setCursor(Cursor.DEFAULT);

                                    return mainController.getSeries();
                                }
                            }
                        };
                        Thread th = new Thread(task);
                        th.setDaemon(true);
                        th.start();
                        stage.close();
                    }
                });
                resultados.getChildren().add(resultadoActual);
            }
        } else {
            resultados.getChildren().add(new Label("La busqueda no obtuvo resultados"));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(NewSerieController.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:dpfmanager.shell.interfaces.gui.fragment.wizard.Wizard1Fragment.java

private void addCheckBox(String id, String name, String path, boolean selected, boolean delete) {
    HBox hbox = new HBox();
    hbox.setAlignment(Pos.CENTER_LEFT);

    CheckBox chk = new CheckBox(name);
    chk.setId(id);// w ww  . j  a v  a 2 s. co m
    chk.getStyleClass().add("checkreport");
    chk.setSelected(selected);
    chk.setEllipsisString(" ... ");
    chk.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
    chk.setTooltip(new Tooltip(path));
    hbox.getChildren().add(chk);

    // EDIT
    Button edit = new Button();
    edit.getStyleClass().addAll("edit-img", "action-img-16");
    edit.setCursor(Cursor.HAND);
    edit.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            String iso = chk.getId();
            String path = null;
            if (iso.startsWith("external")) {
                iso = chk.getText();
                path = iso;
            } else if (chk.getId().startsWith("config")) {
                iso = chk.getId().replace("config", "");
                path = DPFManagerProperties.getIsosDir() + "/" + iso;
            }
            controller.editIso(iso, path);
        }
    });
    hbox.getChildren().add(edit);
    HBox.setMargin(edit, new Insets(0, 0, 0, 10));

    // DELETE
    if (delete) {
        Button icon = new Button();
        icon.getStyleClass().addAll("delete-img", "action-img-16");
        icon.setCursor(Cursor.HAND);
        icon.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                if (chk.getId().startsWith("external")) {
                    // Only from gui
                    vboxRadios.getChildren().remove(hbox);
                } else if (chk.getId().startsWith("config")) {
                    // From system
                    String name = chk.getId().replace("config", "");
                    File file = new File(DPFManagerProperties.getIsosDir() + "/" + name);
                    if (file.exists() && file.isFile() && acceptDelete(file)) {
                        file.delete();
                        vboxRadios.getChildren().remove(hbox);
                    }
                }
            }
        });
        hbox.getChildren().add(icon);
        HBox.setMargin(icon, new Insets(0, 0, 0, 10));
    }

    vboxRadios.getChildren().add(hbox);
}