Example usage for javafx.scene.layout GridPane setHgap

List of usage examples for javafx.scene.layout GridPane setHgap

Introduction

In this page you can find the example usage for javafx.scene.layout GridPane setHgap.

Prototype

public final void setHgap(double value) 

Source Link

Usage

From source file:kz.aksay.polygraph.desktop.LoginPane.java

public LoginPane() {
    GridPane grid = this;

    grid.setAlignment(Pos.CENTER);//from   w  w w .  j a v  a  2  s. c om
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    sceneTitle = new Text(" ");
    sceneTitle.setId("welcome-text");
    grid.add(sceneTitle, 0, 0, 2, 1);

    userName = new Label(":");
    grid.add(userName, 0, 1);

    userTextField = new TextField();
    grid.add(userTextField, 1, 1);

    password = new Label(":");
    grid.add(password, 0, 2);

    passwordTextBox = new PasswordField();
    grid.add(passwordTextBox, 1, 2);

    signIn = new Button("");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(signIn);
    grid.add(hbBtn, 1, 4);

    final Text actionTarget = new Text();
    actionTarget.setId("action-target");
    actionTarget.setWrappingWidth(300);
    grid.add(actionTarget, 0, 6, 2, 1);

    signIn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            if (isSignInSuccess()) {
                onSignInSuccess.handle(e);
            } else {
                actionTarget.setText(
                        "?   .   !");
            }
        }
    });
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    final GridPane grid = new GridPane();
    grid.setPadding(new Insets(10));
    grid.setHgap(10);
    grid.setVgap(5);/*from   ww  w  . j  a  va  2 s  .c  o  m*/

    createControls(grid);
    createClipList(grid);

    final Scene scene = new Scene(grid, 640, 380);
    scene.getStylesheets().add(getClass().getResource("media.css").toString());

    primaryStage.setTitle("AudioClip Example");
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

private GridPane createGridPane() {
    final GridPane gp = new GridPane();
    gp.setPadding(new Insets(10));
    gp.setHgap(20);
    //gp.add(albumCover, 0, 0, 1, GridPane.REMAINING);
    gp.add(title, 1, 0);//from w  ww . j  a v  a 2 s . co  m
    gp.add(artist, 1, 1);
    gp.add(album, 1, 2);
    gp.add(year, 1, 3);

    final ColumnConstraints c0 = new ColumnConstraints();
    final ColumnConstraints c1 = new ColumnConstraints();
    c1.setHgrow(Priority.ALWAYS);
    gp.getColumnConstraints().addAll(c0, c1);

    final RowConstraints r0 = new RowConstraints();
    r0.setValignment(VPos.TOP);
    gp.getRowConstraints().addAll(r0, r0, r0, r0);

    return gp;
}

From source file:Person.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 500, 250, Color.WHITE);
    // create a grid pane
    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);
    gridpane.setVgap(10);// w ww  .j a v a 2 s .c  o  m

    ObservableList<Person> leaders = FXCollections.observableArrayList();
    leaders.add(new Person("A", "B", "C"));
    leaders.add(new Person("D", "E", "F"));
    final ListView<Person> leaderListView = new ListView<Person>(leaders);
    leaderListView.setPrefWidth(150);
    leaderListView.setPrefHeight(150);

    // 
    leaderListView.setCellFactory(new Callback<ListView<Person>, ListCell<Person>>() {

        public ListCell<Person> call(ListView<Person> param) {
            final Label leadLbl = new Label();
            final Tooltip tooltip = new Tooltip();
            final ListCell<Person> cell = new ListCell<Person>() {
                @Override
                public void updateItem(Person item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        leadLbl.setText(item.getAliasName());
                        setText(item.getFirstName() + " " + item.getLastName());
                        tooltip.setText(item.getAliasName());
                        setTooltip(tooltip);
                    }
                }
            }; // ListCell
            return cell;
        }
    }); // setCellFactory

    gridpane.add(leaderListView, 0, 1);

    leaderListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
        public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
            System.out.println("selection changed");
        }
    });

    root.getChildren().add(gridpane);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    final Label label = new Label("Progress:");
    final ProgressBar progressBar = new ProgressBar(0);
    final ProgressIndicator progressIndicator = new ProgressIndicator(0);

    final Button startButton = new Button("Start");
    final Button cancelButton = new Button("Cancel");
    final TextArea textArea = new TextArea();

    startButton.setOnAction((ActionEvent event) -> {
        startButton.setDisable(true);//from   www . j a va2 s  .c om

        progressBar.setProgress(0);
        progressIndicator.setProgress(0);

        textArea.setText("");
        cancelButton.setDisable(false);

        copyWorker = createWorker(numFiles);

        progressBar.progressProperty().unbind();
        progressBar.progressProperty().bind(copyWorker.progressProperty());
        progressIndicator.progressProperty().unbind();
        progressIndicator.progressProperty().bind(copyWorker.progressProperty());

        copyWorker.messageProperty().addListener(
                (ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
                    textArea.appendText(newValue + "\n");
                });

        new Thread(copyWorker).start();
    });

    cancelButton.setOnAction((ActionEvent event) -> {
        startButton.setDisable(false);
        cancelButton.setDisable(true);
        copyWorker.cancel(true);

        progressBar.progressProperty().unbind();
        progressBar.setProgress(0);
        progressIndicator.progressProperty().unbind();
        progressIndicator.setProgress(0);
        textArea.appendText("File transfer was cancelled.");
    });

    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 500, 250, javafx.scene.paint.Color.WHITE);

    FlowPane topPane = new FlowPane(5, 5);
    topPane.setPadding(new Insets(5));
    topPane.setAlignment(Pos.CENTER);
    topPane.getChildren().addAll(label, progressBar, progressIndicator);

    GridPane middlePane = new GridPane();
    middlePane.setPadding(new Insets(5));
    middlePane.setHgap(20);
    middlePane.setVgap(20);
    ColumnConstraints column1 = new ColumnConstraints(300, 400, Double.MAX_VALUE);
    middlePane.getColumnConstraints().addAll(column1);
    middlePane.setAlignment(Pos.CENTER);
    middlePane.add(textArea, 0, 0);

    FlowPane bottomPane = new FlowPane(5, 5);
    bottomPane.setPadding(new Insets(5));
    bottomPane.setAlignment(Pos.CENTER);
    bottomPane.getChildren().addAll(startButton, cancelButton);

    root.setTop(topPane);
    root.setCenter(middlePane);
    root.setBottom(bottomPane);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:de.perdoctus.ebikeconnect.gui.dialogs.LoginDialog.java

@PostConstruct
public void init() {
    final ImageView graphic = new ImageView(
            new Image(getClass().getResource("/app-icon.png").toExternalForm()));
    graphic.setPreserveRatio(true);/*from ww w  .ja v a  2 s  .  c  om*/
    graphic.setFitHeight(64);
    setGraphic(graphic);
    setResizable(true);
    setWidth(400);
    setResizable(false);

    setTitle(rb.getString("dialogTitle"));
    setHeaderText(rb.getString("dialogMessage"));

    final ButtonType loginButtonType = new ButtonType(rb.getString("loginButton"),
            ButtonBar.ButtonData.OK_DONE);
    getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

    // Create the username and password labels and fields.
    final GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 10, 10, 10));
    grid.setPrefWidth(getWidth());
    grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.LEFT, true));
    grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.ALWAYS, HPos.LEFT, true));

    final String rbUsername = rb.getString(CFG_USERNAME);
    final TextField txtUsername = new TextField();
    txtUsername.setPromptText(rbUsername);
    txtUsername.setText(config.getString(CFG_USERNAME, ""));

    final Label lblUsername = new Label(rbUsername);
    lblUsername.setLabelFor(txtUsername);
    grid.add(lblUsername, 0, 0);
    grid.add(txtUsername, 1, 0);

    final String rbPassword = rb.getString(CFG_PASSWORD);
    final PasswordField txtPassword = new PasswordField();
    txtPassword.setPromptText(rbPassword);
    if (config.getBoolean(CFG_SAVE_PASSWORD, false)) {
        txtPassword.setText(config.getString(CFG_PASSWORD, ""));
    }

    final Label lblPassword = new Label(rbPassword);
    lblPassword.setLabelFor(txtPassword);
    grid.add(lblPassword, 0, 1);
    grid.add(txtPassword, 1, 1);

    final CheckBox cbSavePassword = new CheckBox(rb.getString("save-password"));
    cbSavePassword.setSelected(config.getBoolean(CFG_SAVE_PASSWORD, false));
    grid.add(cbSavePassword, 1, 2);

    getDialogPane().setContent(grid);

    // Enable/Disable login button depending on whether a username was entered.
    final Node loginButton = getDialogPane().lookupButton(loginButtonType);
    loginButton.disableProperty()
            .bind(txtUsername.textProperty().isEmpty().or(txtPassword.textProperty().isEmpty()));

    setResultConverter(buttonType -> {
        if (buttonType == loginButtonType) {
            config.setProperty(CFG_USERNAME, txtUsername.getText());
            config.setProperty(CFG_SAVE_PASSWORD, cbSavePassword.isSelected());
            if (cbSavePassword.isSelected()) {
                config.setProperty(CFG_PASSWORD, txtPassword.getText());
                config.setProperty(CFG_PASSWORD, txtPassword.getText());
            } else {
                config.clearProperty(CFG_PASSWORD);
            }
            return new Credentials(txtUsername.getText(), txtPassword.getText());
        } else {
            return null;
        }
    });

    if (txtUsername.getText().isEmpty()) {
        txtUsername.requestFocus();
    } else {
        txtPassword.requestFocus();
        txtPassword.selectAll();
    }
}

From source file:Main.java

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

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);
    gridpane.setVgap(10);//from  ww w .j  a  va  2s  .  com
    root.setCenter(gridpane);

    ObservableList<Person> leaders = getPeople();
    final ObservableList<Person> teamMembers = FXCollections.observableArrayList();

    ListView<Person> leaderListView = createLeaderListView(leaders);
    TableView<Person> employeeTableView = createEmployeeTableView(teamMembers);

    Label bossesLbl = new Label("Boss");
    GridPane.setHalignment(bossesLbl, HPos.CENTER);
    gridpane.add(bossesLbl, 0, 0);
    gridpane.add(leaderListView, 0, 1);

    Label emplLbl = new Label("Employees");
    GridPane.setHalignment(emplLbl, HPos.CENTER);
    gridpane.add(emplLbl, 2, 0);
    gridpane.add(employeeTableView, 2, 1);

    leaderListView.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends Person> observable, Person oldValue, Person newValue) -> {
                if (observable != null && observable.getValue() != null) {
                    teamMembers.clear();
                    teamMembers.addAll(observable.getValue().employeesProperty());
                }
            });
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:jobhunter.gui.dialog.SubscriptionForm.java

public Optional<Action> show() {
    Dialog dlg = new Dialog(null, getTranslation("message.add.subscription"));

    final GridPane content = new GridPane();
    content.setHgap(10);
    content.setVgap(10);//from w ww .j  a  va2s . c om

    ObservableList<String> portals = FXCollections.observableArrayList(PreferencesController.getPortalsList());

    portalField.setItems(portals);
    portalField.setPrefWidth(400.0);
    portalField.setEditable(true);

    portalField.setValue(subscription.getPortal());
    portalField.valueProperty().addListener((observable, old, neu) -> {
        subscription.setPortal(neu);
        save.disabledProperty().set(!isValid());
    });

    urlField.setText(subscription.getUri());
    urlField.textProperty().addListener((observable, old, neu) -> {
        subscription.setURI(neu);
        save.disabledProperty().set(!isValid());
    });

    titleField.setText(subscription.getTitle());
    titleField.textProperty().addListener((observable, old, neu) -> {
        subscription.setTitle(neu);
        save.disabledProperty().set(!isValid());
    });

    historyField.setText(subscription.getHistory().toString());
    historyField.textProperty().addListener((observable, old, neu) -> {
        subscription.setHistory(Integer.valueOf(neu));
        save.disabledProperty().set(!isValid());
    });

    content.add(new Label(getTranslation("label.title")), 0, 0);
    content.add(titleField, 1, 0);
    GridPane.setHgrow(titleField, Priority.ALWAYS);

    content.add(new Label(getTranslation("label.portal")), 0, 1);
    content.add(portalField, 1, 1);

    content.add(new Label(getTranslation("label.feed.url")), 0, 2);
    content.add(urlField, 1, 2);
    GridPane.setHgrow(urlField, Priority.ALWAYS);

    content.add(new Label(getTranslation("label.history")), 0, 3);
    content.add(historyField, 1, 3);
    GridPane.setHgrow(historyField, Priority.ALWAYS);

    dlg.setResizable(false);
    dlg.setIconifiable(false);
    dlg.setContent(content);
    dlg.getActions().addAll(save, Dialog.Actions.CANCEL);

    Platform.runLater(() -> titleField.requestFocus());

    l.debug("Showing dialog");
    return Optional.of(dlg.show());
}

From source file:eu.over9000.skadi.ui.dialogs.PerformUpdateDialog.java

public PerformUpdateDialog(RemoteVersionResult newVersion) {
    this.chosen = new SimpleObjectProperty<>(
            Paths.get(SystemUtils.USER_HOME, newVersion.getVersion() + ".jar").toFile());

    this.setHeaderText("Updating to " + newVersion.getVersion());
    this.setTitle("Skadi Updater");
    this.getDialogPane().getStyleClass().add("alert");
    this.getDialogPane().getStyleClass().add("information");

    final ButtonType restartButtonType = new ButtonType("Start New Version", ButtonBar.ButtonData.OK_DONE);
    this.getDialogPane().getButtonTypes().addAll(restartButtonType, ButtonType.CANCEL);

    Node btn = this.getDialogPane().lookupButton(restartButtonType);
    btn.setDisable(true);/*from   ww w  .  j  ava2  s.c  om*/

    Label lbPath = new Label("Save as");
    TextField tfPath = new TextField();
    tfPath.textProperty()
            .bind(Bindings.createStringBinding(() -> this.chosen.get().getAbsolutePath(), this.chosen));
    tfPath.setPrefColumnCount(40);
    tfPath.setEditable(false);

    Button btChangePath = GlyphsDude.createIconButton(FontAwesomeIcons.FOLDER_OPEN, "Browse...");
    btChangePath.setOnAction(event -> {
        FileChooser fc = new FileChooser();
        fc.setTitle("Save downloaded jar..");
        fc.setInitialFileName(this.chosen.getValue().getName());
        fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("Jar File", ".jar"));
        fc.setInitialDirectory(this.chosen.getValue().getParentFile());
        File selected = fc.showSaveDialog(this.getOwner());
        if (selected != null) {
            this.chosen.set(selected);
        }
    });

    ProgressBar pbDownload = new ProgressBar(0);
    pbDownload.setDisable(true);
    pbDownload.setMaxWidth(Double.MAX_VALUE);
    Label lbDownload = new Label("Download");
    Label lbDownloadValue = new Label();
    Button btDownload = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD, "Start");
    btDownload.setMaxWidth(Double.MAX_VALUE);
    btDownload.setOnAction(event -> {
        btChangePath.setDisable(true);
        btDownload.setDisable(true);

        this.downloadService = new DownloadService(newVersion.getDownloadURL(), this.chosen.getValue());

        lbDownloadValue.textProperty().bind(this.downloadService.messageProperty());
        pbDownload.progressProperty().bind(this.downloadService.progressProperty());

        this.downloadService.setOnSucceeded(dlEvent -> {
            btn.setDisable(false);
        });
        this.downloadService.setOnFailed(dlFailed -> {
            LOGGER.error("new version download failed", dlFailed.getSource().getException());
            lbDownloadValue.textProperty().unbind();
            lbDownloadValue.setText("Download failed, check log file for details.");
        });

        this.downloadService.start();
    });

    final GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);

    grid.add(lbPath, 0, 0);
    grid.add(tfPath, 1, 0);
    grid.add(btChangePath, 2, 0);
    grid.add(new Separator(), 0, 1, 3, 1);
    grid.add(lbDownload, 0, 2);
    grid.add(pbDownload, 1, 2);
    grid.add(btDownload, 2, 2);
    grid.add(lbDownloadValue, 1, 3);

    this.getDialogPane().setContent(grid);

    this.setResultConverter(btnType -> {
        if (btnType == restartButtonType) {
            return this.chosen.getValue();
        }

        if (btnType == ButtonType.CANCEL) {
            if (this.downloadService.isRunning()) {
                this.downloadService.cancel();
            }
        }

        return null;
    });

}

From source file:eu.over9000.skadi.ui.dialogs.UpdateAvailableDialog.java

public UpdateAvailableDialog(RemoteVersionResult newVersion) {
    super(AlertType.INFORMATION, null, UPDATE_BUTTON_TYPE, IGNORE_BUTTON_TYPE);

    this.setTitle("Update available");
    this.setHeaderText(newVersion.getVersion() + " is available");

    Label lbChangeLog = new Label("Changelog:");
    TextArea taChangeLog = new TextArea(newVersion.getChangeLog());
    taChangeLog.setEditable(false);//from w  ww  .ja va 2 s  .  com
    taChangeLog.setWrapText(true);

    Label lbSize = new Label("Size:");
    Label lbSizeValue = new Label(FileUtils.byteCountToDisplaySize(newVersion.getSize()));

    Label lbPublished = new Label("Published");
    Label lbPublishedValue = new Label(
            ZonedDateTime.parse(newVersion.getPublished()).format(DateTimeFormatter.RFC_1123_DATE_TIME));

    final GridPane grid = new GridPane();
    RowConstraints vAlign = new RowConstraints();
    vAlign.setValignment(VPos.TOP);
    grid.getRowConstraints().add(vAlign);
    grid.setHgap(10);
    grid.setVgap(10);

    grid.add(lbChangeLog, 0, 0);
    grid.add(taChangeLog, 1, 0);
    grid.add(lbPublished, 0, 1);
    grid.add(lbPublishedValue, 1, 1);
    grid.add(lbSize, 0, 2);
    grid.add(lbSizeValue, 1, 2);

    this.getDialogPane().setContent(grid);
}