Search in sources :

Example 26 with GridPane

use of javafx.scene.layout.GridPane in project trex-stateless-gui by cisco-system-traffic-generator.

the class CustomTreeItem method buildItem.

/**
     * build custom tree item
     *
     * @param title
     * @param owner
     * @param assignedText
     * @param addIcon
     */
private void buildItem(String title, String owner, String addIcon) {
    GridPane itemContainer = new GridPane();
    // additioanl icon
    if (addIcon != null) {
        Image icon = new Image("/icons/" + addIcon);
        ImageView iconContainer = new ImageView(icon);
        itemContainer.add(iconContainer, 0, 0);
    }
    itemTitle.setText(title);
    itemTitle.getStyleClass().add("treeItemTitle");
    itemContainer.add(itemTitle, 1, 0);
    if (owner != null && !"".equals(owner)) {
        this.owner = new Label("(" + owner + ")");
        this.owner.getStyleClass().add("treeItemChildText");
        itemContainer.add(this.owner, 2, 0);
    }
    Image itemIcon = new Image("/icons/" + treeItemType.getIcon());
    ImageView itemIconContainer = new ImageView(itemIcon);
    setValue(itemContainer);
    setGraphic(itemIconContainer);
}
Also used : GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image)

Example 27 with GridPane

use of javafx.scene.layout.GridPane in project jgnash by ccavanaugh.

the class SelectAccountSecuritiesDialog method createGridPane.

private GridPane createGridPane() {
    final GridPane gridPane = new GridPane();
    gridPane.getStyleClass().add("form");
    final ColumnConstraints col0 = new ColumnConstraints();
    col0.setFillWidth(true);
    col0.setHgrow(Priority.ALWAYS);
    col0.setMaxWidth(Double.MAX_VALUE);
    col0.setPrefWidth(220);
    final ColumnConstraints col1 = new ColumnConstraints();
    col1.setFillWidth(true);
    col1.setHgrow(Priority.NEVER);
    final ColumnConstraints col2 = new ColumnConstraints();
    col2.setFillWidth(true);
    col2.setHgrow(Priority.ALWAYS);
    col2.setMaxWidth(Double.MAX_VALUE);
    col2.setPrefWidth(220);
    gridPane.getColumnConstraints().addAll(col0, col1, col2);
    final RowConstraints row0 = new RowConstraints();
    row0.setFillHeight(true);
    row0.setVgrow(Priority.NEVER);
    final RowConstraints row1 = new RowConstraints();
    row1.setMaxHeight(Double.MAX_VALUE);
    row1.setPrefHeight(220);
    row1.setVgrow(Priority.ALWAYS);
    final RowConstraints row2 = new RowConstraints();
    row0.setFillHeight(true);
    row0.setVgrow(Priority.NEVER);
    gridPane.getRowConstraints().addAll(row0, row1, row2);
    return gridPane;
}
Also used : GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) RowConstraints(javafx.scene.layout.RowConstraints)

Example 28 with GridPane

use of javafx.scene.layout.GridPane in project jgnash by ccavanaugh.

the class NetworkAuthenticator method getPasswordAuthentication.

@Override
protected PasswordAuthentication getPasswordAuthentication() {
    final Preferences auth = Preferences.userRoot().node(NODEHTTP);
    final ResourceBundle resources = ResourceUtils.getBundle();
    final char[][] pass = { null };
    final String[] user = new String[1];
    // get the password
    if (auth.get(HTTPPASS, null) != null && !auth.get(HTTPPASS, null).isEmpty()) {
        pass[0] = auth.get(HTTPPASS, null).toCharArray();
    }
    // get the user
    user[0] = auth.get(HTTPUSER, null);
    if (user[0] != null) {
        if (user[0].length() <= 0) {
            user[0] = null;
        }
    }
    // if either returns null, pop a dialog
    if (user[0] == null || pass[0] == null) {
        final Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle(resources.getString("Title.HTTPProxy"));
        dialog.setHeaderText(resources.getString("Message.EnterNetworkAuth"));
        // Set the button types.
        final ButtonType loginButtonType = new ButtonType(resources.getString("Button.Ok"), ButtonBar.ButtonData.OK_DONE);
        dialog.getDialogPane().getStylesheets().addAll(MainView.DEFAULT_CSS);
        dialog.getDialogPane().getStyleClass().addAll("dialog");
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
        // Create the username and password labels and fields.
        final GridPane grid = new GridPane();
        grid.getStylesheets().addAll(MainView.DEFAULT_CSS);
        grid.getStyleClass().addAll("form");
        final TextField userNameField = new TextField();
        final PasswordField passwordField = new PasswordField();
        grid.add(new Label(resources.getString("Label.UserName")), 0, 0);
        grid.add(userNameField, 1, 0);
        grid.add(new Label(resources.getString("Label.Password")), 0, 1);
        grid.add(passwordField, 1, 1);
        // Enable/Disable login button depending on whether a username was entered.
        final Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);
        // bind the button, must not be empty
        loginButton.disableProperty().bind(userNameField.textProperty().isEmpty());
        dialog.getDialogPane().setContent(grid);
        // Request focus on the username field by default.
        Platform.runLater(userNameField::requestFocus);
        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(userNameField.getText(), passwordField.getText());
            }
            return null;
        });
        final Optional<Pair<String, String>> result = dialog.showAndWait();
        result.ifPresent(usernamePassword -> {
            user[0] = usernamePassword.getKey();
            pass[0] = usernamePassword.getValue().toCharArray();
        });
    }
    return new PasswordAuthentication(user[0], pass[0]);
}
Also used : GridPane(javafx.scene.layout.GridPane) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Dialog(javafx.scene.control.Dialog) TextField(javafx.scene.control.TextField) ResourceBundle(java.util.ResourceBundle) PasswordField(javafx.scene.control.PasswordField) Preferences(java.util.prefs.Preferences) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair) PasswordAuthentication(java.net.PasswordAuthentication)

Aggregations

GridPane (javafx.scene.layout.GridPane)28 Label (javafx.scene.control.Label)19 Insets (javafx.geometry.Insets)8 Button (javafx.scene.control.Button)7 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)7 Dialog (javafx.scene.control.Dialog)6 TextField (javafx.scene.control.TextField)6 VBox (javafx.scene.layout.VBox)6 Scene (javafx.scene.Scene)5 Text (javafx.scene.text.Text)5 Stage (javafx.stage.Stage)5 Pair (javafx.util.Pair)5 ButtonType (javafx.scene.control.ButtonType)4 Region (javafx.scene.layout.Region)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Node (javafx.scene.Node)3 ColumnConstraintsWithPercentage (org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage)3 File (java.io.File)2 ResourceBundle (java.util.ResourceBundle)2