Java Code Examples for javafx.scene.control.Button#setDefaultButton()

The following examples show how to use javafx.scene.control.Button#setDefaultButton() . 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: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, InputTextField, Button> addTopLabelInputTextFieldButton(GridPane gridPane,
                                                                                    int rowIndex,
                                                                                    String title,
                                                                                    String buttonTitle) {
    InputTextField inputTextField = new InputTextField();
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(inputTextField, button);
    HBox.setHgrow(inputTextField, Priority.ALWAYS);

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

    return new Tuple3<>(labelVBoxTuple2.first, inputTextField, button);
}
 
Example 2
Source File: ScenarioConfigEditorFX.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public boolean confirmDeleteDialog(String header, String text) {
	Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
	dialog.initOwner(stage);
	dialog.setHeaderText(header);
	dialog.setContentText(text);
	dialog.getDialogPane().setPrefSize(300, 180);
	// ButtonType buttonTypeYes = new ButtonType("Yes");
	// ButtonType buttonTypeNo = new ButtonType("No");
	// dialog.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);
	dialog.getButtonTypes().clear();
	dialog.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);
	// Deactivate Defaultbehavior for yes-Button:
	Button yesButton = (Button) dialog.getDialogPane().lookupButton(ButtonType.YES);
	yesButton.setDefaultButton(false);
	// Activate Defaultbehavior for no-Button:
	Button noButton = (Button) dialog.getDialogPane().lookupButton(ButtonType.NO);
	noButton.setDefaultButton(true);
	final Optional<ButtonType> result = dialog.showAndWait();
	// return result.get() == buttonTypeYes;
	return result.get() == ButtonType.YES;
}
 
Example 3
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, Button, Button> addTopLabel2Buttons(GridPane gridPane,
                                                                int rowIndex,
                                                                String labelText,
                                                                String title1,
                                                                String title2,
                                                                double top) {
    HBox hBox = new HBox();
    hBox.setSpacing(10);

    Button button1 = new AutoTooltipButton(title1);
    button1.setDefaultButton(true);
    button1.getStyleClass().add("action-button");
    button1.setDefaultButton(true);
    button1.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button1, Priority.ALWAYS);

    Button button2 = new AutoTooltipButton(title2);
    button2.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button2, Priority.ALWAYS);

    hBox.getChildren().addAll(button1, button2);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, labelText, hBox, top);

    return new Tuple3<>(topLabelWithVBox.first, button1, button2);
}
 
Example 4
Source File: TimeRangeDialog.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
public TimeRangeDialog(final TimeRelativeInterval range)
{
    times.setInterval(range);
    setTitle(Messages.TimeColumn);
    getDialogPane().setContent(times);
    getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL);

    // TimeRelativeIntervalPane works fine standalone,
    // but when hosted in dialog 'enter' is not possible
    // on the date fields because OK button captures 'Enter'.
    // --> Disable the 'default' behavior of OK button.
    final Button ok = (Button)getDialogPane().lookupButton(ButtonType.OK);
    ok.setDefaultButton(false);

    setResultConverter(button ->
    {
        if (button == ButtonType.OK)
            return times.getInterval();
        return null;
    });
}
 
Example 5
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Button, CheckBox> addButtonCheckBox(GridPane gridPane,
                                                         int rowIndex,
                                                         String buttonTitle,
                                                         String checkBoxTitle,
                                                         double top) {
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);
    CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle);
    HBox.setMargin(checkBox, new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(20);
    hBox.getChildren().addAll(button, checkBox);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.setPadding(new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple2<>(button, checkBox);
}
 
Example 6
Source File: TranslationChoiceDialog.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create the translation choice dialog.
 */
public TranslationChoiceDialog() {
    initModality(Modality.APPLICATION_MODAL);
    setTitle(LabelGrabber.INSTANCE.getLabel("translation.choice.title"));
    Utils.addIconsToStage(this);
    BorderPane root = new BorderPane();
    content = new VBox(5);
    BorderPane.setMargin(content, new Insets(10));
    root.setCenter(content);

    Label selectTranslationLabel = new Label(LabelGrabber.INSTANCE.getLabel("select.translation.label"));
    selectTranslationLabel.setWrapText(true);
    content.getChildren().add(selectTranslationLabel);

    Button okButton = new Button(LabelGrabber.INSTANCE.getLabel("close.button"));
    okButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            hide();
        }
    });
    okButton.setDefaultButton(true);
    StackPane.setMargin(okButton, new Insets(5));
    StackPane buttonPane = new StackPane();
    buttonPane.setAlignment(Pos.CENTER);
    buttonPane.getChildren().add(okButton);
    root.setBottom(buttonPane);

    Scene scene = new Scene(root);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    setScene(scene);
}
 
Example 7
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple3<Button, Button, Button> add3Buttons(GridPane gridPane,
                                                         int rowIndex,
                                                         String title1,
                                                         String title2,
                                                         String title3,
                                                         double top) {
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    Button button1 = new AutoTooltipButton(title1);

    button1.getStyleClass().add("action-button");
    button1.setDefaultButton(true);
    button1.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button1, Priority.ALWAYS);

    Button button2 = new AutoTooltipButton(title2);
    button2.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button2, Priority.ALWAYS);

    Button button3 = new AutoTooltipButton(title3);
    button3.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button3, Priority.ALWAYS);

    hBox.getChildren().addAll(button1, button2, button3);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 0);
    GridPane.setMargin(hBox, new Insets(top, 10, 0, 0));
    gridPane.getChildren().add(hBox);
    return new Tuple3<>(button1, button2, button3);
}
 
Example 8
Source File: GamePresenter.java    From Game2048FX with GNU General Public License v3.0 5 votes vote down vote up
private void showSignInDialog(String message) {
    // force login view
    HBox title = new HBox(10);
    title.setAlignment(Pos.CENTER_LEFT);
    title.getChildren().add(new ImageView());
    title.getChildren().add(new Label("Sign in required"));
    Dialog<ButtonType> dialog = new Dialog();
    dialog.setContent(new Label(message + ", you have to sign in\nwith your social network profile. \nDo you want to continue?"));
    dialog.setTitle(title);
    Button yes = new Button("Yes");
    yes.setOnAction(e -> {
        dialog.setResult(ButtonType.YES);
        dialog.hide();
    });
    yes.setDefaultButton(true);
    Button no = new Button("No");
    no.setCancelButton(true);
    no.setOnAction(e -> {
        dialog.setResult(ButtonType.NO);
        dialog.hide();
    });
    dialog.getButtons().addAll(yes, no);
    Platform.runLater(() -> {
        Optional result = dialog.showAndWait();
        if (result.isPresent() && result.get().equals(ButtonType.YES)) {
            cloud.forceLogin();
        }
    });
}
 
Example 9
Source File: WebViewSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public WebViewSample() {
    WebView webView = new WebView();
    
    final WebEngine webEngine = webView.getEngine();
    webEngine.load(DEFAULT_URL);
    
    final TextField locationField = new TextField(DEFAULT_URL);
    webEngine.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            webEngine.load(locationField.getText().startsWith("http://") 
                    ? locationField.getText() 
                    : "http://" + locationField.getText());
        }
    };
    locationField.setOnAction(goAction);
    
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    goButton.setOnAction(goAction);
    
    // Layout logic
    HBox hBox = new HBox(5);
    hBox.getChildren().setAll(locationField, goButton);
    HBox.setHgrow(locationField, Priority.ALWAYS);
    
    VBox vBox = new VBox(5);
    vBox.getChildren().setAll(hBox, webView);
    VBox.setVgrow(webView, Priority.ALWAYS);

    getChildren().add(vBox);
}
 
Example 10
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple2<Label, Button> addTopLabelButton(GridPane gridPane,
                                                      int rowIndex,
                                                      String labelText,
                                                      String buttonTitle,
                                                      double top) {
    Button button = new AutoTooltipButton(buttonTitle);
    button.setDefaultButton(true);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, labelText, button, top);

    return new Tuple2<>(topLabelWithVBox.first, button);
}
 
Example 11
Source File: WebViewBrowser.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
Example 12
Source File: SettingsPresenter.java    From Game2048FX with GNU General Public License v3.0 5 votes vote down vote up
private void showAlertDialog(GameMode mode) {
    HBox title = new HBox(10);
    title.setAlignment(Pos.CENTER_LEFT);
    title.getChildren().add(new ImageView());
    title.getChildren().add(new Label("Game will be restarted"));
    Dialog<ButtonType> dialog = new Dialog();
    dialog.setContent(new Label("The game will be restarted and non saved data will be lost. \nDo you want to continue?"));
    dialog.setTitle(title);
    Button yes = new Button("Yes");
    yes.setOnAction(e -> {
        dialog.setResult(ButtonType.YES);
        dialog.hide();
    });
    yes.setDefaultButton(true);
    Button no = new Button("No");
    no.setCancelButton(true);
    no.setOnAction(e -> {
        dialog.setResult(ButtonType.NO);
        dialog.hide();
    });
    dialog.getButtons().addAll(yes, no);
    Platform.runLater(() -> {
        Optional result = dialog.showAndWait();
        if (result.isPresent() && result.get().equals(ButtonType.YES)) {
            gameModel.setGameMode(mode);
        } else {
            gameMode.set(gameModel.getGameMode());
        }
        getApp().switchToPreviousView();
    });
}
 
Example 13
Source File: CommentsPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Create a Dialog for getting deletion confirmation
 * @param item Item to be deleted
 */
private void showDialog(Comment item) {
    Alert alert = new Alert(javafx.scene.control.Alert.AlertType.CONFIRMATION);
    alert.setTitleText("Confirm deletion");
    alert.setContentText("This comment will be deleted permanently.\nDo you want to continue?");
    
    Button yes = new Button("Yes, delete permanently");
    yes.setOnAction(e -> {
        alert.setResult(ButtonType.YES); 
        alert.hide();
    });
    yes.setDefaultButton(true);
    
    Button no = new Button("No");
    no.setCancelButton(true);
    no.setOnAction(e -> {
        alert.setResult(ButtonType.NO); 
        alert.hide();
    });
    alert.getButtons().setAll(yes,no);
    
    Optional result = alert.showAndWait();
    if(result.isPresent() && result.get().equals(ButtonType.YES)){
        /*
        With confirmation, delete the item from the ListView. This will be
        propagated to the Cloud, and from here to the rest of the clients
        */
        commentsList.getItems().remove(item);
    }    
}
 
Example 14
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple3<Button, Button, HBox> add2ButtonsWithBox(GridPane gridPane, int rowIndex, String title1,
                                                              String title2, double top, boolean hasPrimaryButton) {
    HBox hBox = new HBox();
    hBox.setSpacing(10);

    Button button1 = new AutoTooltipButton(title1);

    if (hasPrimaryButton) {
        button1.getStyleClass().add("action-button");
        button1.setDefaultButton(true);
    }

    button1.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button1, Priority.ALWAYS);

    Button button2 = new AutoTooltipButton(title2);
    button2.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button2, Priority.ALWAYS);

    hBox.getChildren().addAll(button1, button2);

    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 0);
    GridPane.setMargin(hBox, new Insets(top, 10, 0, 0));
    gridPane.getChildren().add(hBox);
    return new Tuple3<>(button1, button2, hBox);
}
 
Example 15
Source File: PreferencesController.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
private void collectIpCamInfo() {
	final Stage ipcamStage = new Stage();
	final GridPane ipcamPane = new GridPane();

	final ColumnConstraints cc = new ColumnConstraints(400);
	cc.setHalignment(HPos.CENTER);
	ipcamPane.getColumnConstraints().addAll(new ColumnConstraints(), cc);

	final TextField nameTextField = new TextField();
	ipcamPane.add(new Label("IPCam Name:"), 0, 0);
	ipcamPane.add(nameTextField, 1, 0);

	final TextField userTextField = new TextField();
	userTextField.setPromptText("Optional Username");
	ipcamPane.add(new Label("Username:"), 0, 1);
	ipcamPane.add(userTextField, 1, 1);

	final PasswordField passwordField = new PasswordField();
	passwordField.setPromptText("Optional Password");
	ipcamPane.add(new Label("Password:"), 0, 2);
	ipcamPane.add(passwordField, 1, 2);

	final TextField urlTextField = new TextField("http://");
	ipcamPane.add(new Label("IPCam URL:"), 0, 3);
	ipcamPane.add(urlTextField, 1, 3);

	final Button okButton = new Button("OK");
	okButton.setDefaultButton(true);
	ipcamPane.add(okButton, 1, 4);

	okButton.setOnAction((e) -> {
		if (nameTextField.getText().isEmpty() || urlTextField.getText().isEmpty()) {
			final Alert ipcamInfoAlert = new Alert(AlertType.ERROR);
			ipcamInfoAlert.setTitle("Missing Information");
			ipcamInfoAlert.setHeaderText("Missing Required IPCam Information!");
			ipcamInfoAlert.setResizable(true);
			ipcamInfoAlert.setContentText("Please fill in both the IPCam name and the URL.");
			ipcamInfoAlert.showAndWait();
			return;
		}

		Optional<String> username = Optional.empty();
		Optional<String> password = Optional.empty();

		if (!userTextField.getText().isEmpty() || !passwordField.getText().isEmpty()) {
			username = Optional.of(userTextField.getText());
			password = Optional.of(passwordField.getText());
		}

		final Optional<Camera> cam = config.registerIpCam(nameTextField.getText(), urlTextField.getText(), username,
				password);

		if (cam.isPresent()) {
			CheckableImageListCell.cacheCamera(cam.get(), PreferencesController.this);

			if (!configuredCameras.contains(cam.get())) {
				Platform.runLater(() -> {
					webcamListView.setItems(null);
					cameras.add(cam.get().getName());
					webcamListView.setItems(cameras);
				});
			}
		}

		ipcamStage.close();
	});

	final Scene scene = new Scene(ipcamPane);
	ipcamStage.initOwner(preferencesPane.getScene().getWindow());
	ipcamStage.initModality(Modality.WINDOW_MODAL);
	ipcamStage.setTitle("Register IPCam");
	ipcamStage.setScene(scene);
	ipcamStage.showAndWait();
}
 
Example 16
Source File: InfoBox.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
public InfoBox(final Window owner, final String title, final String labelText, 
        final String textAreaText, final boolean editable, final int width, final int height) {
    final VBox pane = new VBox(20);
    pane.setId(StageController.FX_CONNECTOR_BASE_ID + "InfoBox");
    final Scene scene = new Scene(pane, width, height); 

    final Stage stage = new Stage(StageStyle.UTILITY);
    stage.setTitle(title);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(owner);
    stage.setScene(scene);
    stage.getIcons().add(ScenicViewGui.APP_ICON);

    final Label label = new Label(labelText);
    stage.setWidth(width);
    stage.setHeight(height);
    textArea = new TextArea();
    if (textAreaText != null) {
        textArea.setEditable(editable);
        textArea.setText(textAreaText);
        VBox.setMargin(textArea, new Insets(5, 5, 0, 5));
        VBox.setVgrow(textArea, Priority.ALWAYS);
    }
    final Button close = new Button("Close");
    VBox.setMargin(label, new Insets(5, 5, 0, 5));

    VBox.setMargin(close, new Insets(5, 5, 5, 5));

    pane.setAlignment(Pos.CENTER);

    close.setDefaultButton(true);
    close.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(final ActionEvent arg0) {
            stage.close();
        }
    });
    if (textArea != null) {
        pane.getChildren().addAll(label, textArea, close);
    } else {
        pane.getChildren().addAll(label, close);
    }

    stage.show();
}
 
Example 17
Source File: AgentRegistrationView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    columnConstraints1.setMaxWidth(500);
    gridPane.getColumnConstraints().addAll(columnConstraints1);
    root.getChildren().add(gridPane);

    addTitledGroupBg(gridPane, gridRow, 4, Res.get("account.arbitratorRegistration.registration", getRole()));
    TextField pubKeyTextField = addTopLabelTextField(gridPane, gridRow, Res.get("account.arbitratorRegistration.pubKey"),
            model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;

    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);

    Tuple3<Label, ListView<String>, VBox> tuple = FormBuilder.addTopLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<>() {
                final Label label = new AutoTooltipLabel();
                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
                final Button removeButton = new AutoTooltipButton("", icon);
                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });

    languageComboBox = FormBuilder.addComboBox(gridPane, ++gridRow);
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText(Res.get("shared.addLanguage"));
    languageComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());

    Tuple2<Button, Button> buttonButtonTuple2 = add2ButtonsAfterGroup(gridPane, ++gridRow,
            Res.get("account.arbitratorRegistration.register"), Res.get("account.arbitratorRegistration.revoke"));
    Button registerButton = buttonButtonTuple2.first;
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());

    Button revokeButton = buttonButtonTuple2.second;
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());

    final TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2,
            Res.get("shared.information"), Layout.GROUP_DISTANCE);

    titledGroupBg.getStyleClass().add("last");

    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText(Res.get("account.arbitratorRegistration.info.msg", getRole().toLowerCase()));
}
 
Example 18
Source File: About.java    From Game2048FX with GNU General Public License v3.0 4 votes vote down vote up
public About() {
    
    HBox title = new HBox(10);
    title.setAlignment(Pos.CENTER_LEFT);
    title.getChildren().add(new ImageView());
    title.getChildren().add(new Label("About the App"));
    
    Dialog<ButtonType> dialog = new Dialog<>();
    
    Text t00 = new Text("2048");
    t00.getStyleClass().setAll("game-label","game-lblAbout");
    Text t01 = new Text("FX");
    t01.getStyleClass().setAll("game-label","game-lblAbout2");
    Text t02 = new Text(" Game\n");
    t02.getStyleClass().setAll("game-label","game-lblAbout");
    Text t1 = new Text("JavaFX game - " + Platform.getCurrent().name() + " version\n\n");
    t1.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Text t20 = new Text("Powered by ");
    t20.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link11 = new Hyperlink();
    link11.setText("JavaFXPorts");
    link11.setOnAction(e -> browse("http://gluonhq.com/open-source/javafxports/"));
    link11.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t210 = new Text(" & ");
    t210.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link12 = new Hyperlink();
    link12.setText("Gluon Mobile");
    link12.setOnAction(e -> browse("https://gluonhq.com/products/mobile/"));
    link12.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t21 = new Text(" Projects \n\n");
    t21.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Text t23 = new Text("\u00A9 ");
    t23.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link2 = new Hyperlink();
    link2.setText("José Pereda");
    link2.setOnAction(e -> browse("https://twitter.com/JPeredaDnr"));
    link2.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t22 = new Text(", ");
    t22.getStyleClass().setAll("game-label", "game-lblAboutSub");
    Hyperlink link3 = new Hyperlink();
    link3.setText("Bruno Borges");
    link3.setOnAction(e -> browse("https://twitter.com/brunoborges"));
    Text t32 = new Text(" & ");
    t32.getStyleClass().setAll("game-label", "game-lblAboutSub");
    link3.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Hyperlink link4 = new Hyperlink();
    link4.setText("Jens Deters");
    link4.setOnAction(e -> browse("https://twitter.com/Jerady"));
    link4.getStyleClass().setAll("game-label", "game-lblAboutSub2");
    Text t24 = new Text("\n\n");
    t24.getStyleClass().setAll("game-label", "game-lblAboutSub");

    Text t31 = new Text(" Version " + Game2048.VERSION + " - " + Year.now().toString() + "\n\n");
    t31.getStyleClass().setAll("game-label", "game-lblAboutSub");

    TextFlow flow = new TextFlow();
    flow.setTextAlignment(TextAlignment.CENTER);
    flow.setPadding(new Insets(10,0,0,0));

    flow.getChildren().setAll(t00, t01, t02, t1, t20, link11, t210, link12, t21, t23, link2, t22, link3);
    flow.getChildren().addAll(t32, link4);
    flow.getChildren().addAll(t24, t31);
    
    final ImageView imageView = new ImageView();
    imageView.getStyleClass().add("about");
    
    double scale = Services.get(DisplayService.class)
            .map(display -> {
                if (display.isTablet()) {
                    flow.setTranslateY(30);
                    return 1.3;
                } else {
                    flow.setTranslateY(25);
                    return 1.0;
                }
            })
            .orElse(1.0);
    
    imageView.setFitWidth(270 * scale);
    imageView.setFitHeight(270 * scale);
    imageView.setOpacity(0.1);
    
    dialog.setContent(new StackPane(imageView, flow));
    dialog.setTitle(title);
    
    Button yes = new Button("Accept");
    yes.setOnAction(e -> {
        dialog.setResult(ButtonType.YES); 
        dialog.hide();
    });
    yes.setDefaultButton(true);
    dialog.getButtons().addAll(yes);
    javafx.application.Platform.runLater(dialog::showAndWait);
}
 
Example 19
Source File: DialogControl.java    From WorkbenchFX with Apache License 2.0 4 votes vote down vote up
private void updateButtons(WorkbenchDialog dialog) {
  LOGGER.trace("Updating buttons");

  buttons.clear();
  cancelButton = null;
  cancelButtonType = null;
  defaultButton = null;
  defaultButtonType = null;
  buttonNodes.clear();

  if (Objects.isNull(dialog)) {
    return;
  }

  boolean hasDefault = false;
  for (ButtonType cmd : dialog.getButtonTypes()) {
    Button button = buttonNodes.computeIfAbsent(cmd, dialogButton -> createButton(cmd));

    // keep only first default button
    ButtonBar.ButtonData buttonType = cmd.getButtonData();

    boolean isFirstDefaultButton =
        !hasDefault && buttonType != null && buttonType.isDefaultButton();
    button.setDefaultButton(isFirstDefaultButton);
    if (isFirstDefaultButton) {
      defaultButton = button;
      defaultButtonType = cmd;
    }
    // take last cancel button
    boolean isCancelButton = buttonType != null && buttonType.isCancelButton();
    button.setCancelButton(isCancelButton);
    if (isCancelButton) {
      cancelButton = button;
      cancelButtonType = cmd;
    }
    button.setOnAction(evt -> completeDialog(cmd));

    hasDefault |= buttonType != null && buttonType.isDefaultButton();

    buttons.add(button);

    LOGGER.trace("updateButtons finished");
  }

  updateKeyboardBehavior();
}
 
Example 20
Source File: SendAlertMessageWindow.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addContent() {
    gridPane.getColumnConstraints().get(0).setHalignment(HPos.LEFT);
    gridPane.getColumnConstraints().remove(1);

    InputTextField keyInputTextField = addInputTextField(gridPane, ++rowIndex,
            Res.get("shared.unlock"), 10);
    if (useDevPrivilegeKeys)
        keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);

    Tuple2<Label, TextArea> labelTextAreaTuple2 = addTopLabelTextArea(gridPane, ++rowIndex,
            Res.get("sendAlertMessageWindow.alertMsg"),
            Res.get("sendAlertMessageWindow.enterMsg"));
    TextArea alertMessageTextArea = labelTextAreaTuple2.second;
    Label first = labelTextAreaTuple2.first;
    first.setMinWidth(150);
    CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex,
            Res.get("sendAlertMessageWindow.isUpdate"));
    isUpdateCheckBox.setSelected(true);

    InputTextField versionInputTextField = FormBuilder.addInputTextField(gridPane, ++rowIndex,
            Res.get("sendAlertMessageWindow.version"));
    versionInputTextField.disableProperty().bind(isUpdateCheckBox.selectedProperty().not());

    Button sendButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.send"));
    sendButton.getStyleClass().add("action-button");
    sendButton.setDefaultButton(true);
    sendButton.setOnAction(e -> {
        final String version = versionInputTextField.getText();
        boolean versionOK = false;
        final boolean isUpdate = isUpdateCheckBox.isSelected();
        if (isUpdate) {
            final String[] split = version.split("\\.");
            versionOK = split.length == 3;
            if (!versionOK) // Do not translate as only used by devs
                new Popup().warning("Version number must be in semantic version format (contain 2 '.'). version=" + version)
                        .onClose(this::blurAgain)
                        .show();
        }
        if (!isUpdate || versionOK) {
            if (alertMessageTextArea.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
                if (alertManager.addAlertMessageIfKeyIsValid(
                        new Alert(alertMessageTextArea.getText(), isUpdate, version),
                        keyInputTextField.getText())
                )
                    hide();
                else
                    new Popup().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
            }
        }
    });

    Button removeAlertMessageButton = new AutoTooltipButton(Res.get("sendAlertMessageWindow.remove"));
    removeAlertMessageButton.setOnAction(e -> {
        if (keyInputTextField.getText().length() > 0) {
            if (alertManager.removeAlertMessageIfKeyIsValid(keyInputTextField.getText()))
                hide();
            else
                new Popup().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
        }
    });

    closeButton = new AutoTooltipButton(Res.get("shared.close"));
    closeButton.setOnAction(e -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    hBox.getChildren().addAll(sendButton, removeAlertMessageButton, closeButton);
    gridPane.getChildren().add(hBox);
    GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}