Java Code Examples for javafx.scene.layout.GridPane#setHalignment()

The following examples show how to use javafx.scene.layout.GridPane#setHalignment() . 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 Tuple2<Label, Button> addConfirmationLabelButton(GridPane gridPane,
                                                               int rowIndex,
                                                               String labelText,
                                                               String buttonTitle,
                                                               double top) {
    Label label = addLabel(gridPane, rowIndex, labelText);
    label.getStyleClass().add("confirmation-label");

    Button button = new AutoTooltipButton(buttonTitle);
    button.getStyleClass().add("confirmation-value");
    button.setDefaultButton(true);

    GridPane.setColumnIndex(button, 1);
    GridPane.setRowIndex(button, rowIndex);
    GridPane.setMargin(label, new Insets(top, 0, 0, 0));
    GridPane.setHalignment(label, HPos.LEFT);
    GridPane.setMargin(button, new Insets(top, 0, 0, 0));

    gridPane.getChildren().add(button);

    return new Tuple2<>(label, button);
}
 
Example 2
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void addHeadLine() {
    if (headLine != null) {
        ++rowIndex;

        HBox hBox = new HBox();
        hBox.setSpacing(7);
        headLineLabel = new AutoTooltipLabel(headLine);
        headlineIcon = new Label();
        headlineIcon.setManaged(false);
        headlineIcon.setVisible(false);
        headlineIcon.setPadding(new Insets(3));
        headLineLabel.setMouseTransparent(true);

        if (headlineStyle != null)
            headLineLabel.setStyle(headlineStyle);

        hBox.getChildren().addAll(headlineIcon, headLineLabel);

        GridPane.setHalignment(hBox, HPos.LEFT);
        GridPane.setRowIndex(hBox, rowIndex);
        GridPane.setColumnSpan(hBox, 2);
        gridPane.getChildren().addAll(hBox);
    }
}
 
Example 3
Source File: RadioButtonDrivenTextFieldsPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public void addRow(RadioButton radio, Region field, Text helpIcon) {
    requireNotNullArg(radio, "Cannot add a null radio");
    requireNotNullArg(field, "Cannot add a null field");
    GridPane.setValignment(radio, VPos.BOTTOM);
    GridPane.setValignment(field, VPos.BOTTOM);
    GridPane.setHalignment(radio, HPos.LEFT);
    GridPane.setHalignment(field, HPos.LEFT);
    GridPane.setFillWidth(field, true);
    field.setPrefWidth(300);
    field.setDisable(true);
    radio.selectedProperty().addListener((o, oldVal, newVal) -> {
        field.setDisable(!newVal);
        if (newVal) {
            field.requestFocus();
        }
    });
    radio.setToggleGroup(group);
    add(radio, 0, rows);
    add(field, 1, rows);
    if (nonNull(helpIcon)) {
        add(helpIcon, 2, rows);
    }
    rows++;

}
 
Example 4
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, Label> addConfirmationLabelLabel(GridPane gridPane,
                                                             int rowIndex,
                                                             String title1,
                                                             String title2,
                                                             double top) {
    Label label1 = addLabel(gridPane, rowIndex, title1);
    label1.getStyleClass().add("confirmation-label");
    Label label2 = addLabel(gridPane, rowIndex, title2);
    label2.getStyleClass().add("confirmation-value");
    GridPane.setColumnIndex(label2, 1);
    GridPane.setMargin(label1, new Insets(top, 0, 0, 0));
    GridPane.setHalignment(label1, HPos.LEFT);
    GridPane.setMargin(label2, new Insets(top, 0, 0, 0));

    return new Tuple2<>(label1, label2);
}
 
Example 5
Source File: DisplayUpdateDownloadWindow.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void addButtons() {
    closeButton = new AutoTooltipButton(Res.get("displayUpdateDownloadWindow.button.ignoreDownload"));
    closeButton.setOnAction(event -> doClose());
    actionButton = new AutoTooltipButton(Res.get("displayUpdateDownloadWindow.button.downloadLater"));
    actionButton.setDefaultButton(false);
    actionButton.setOnAction(event -> {
        cleanup();
        hide();
        actionHandlerOptional.ifPresent(Runnable::run);
    });

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(closeButton, actionButton);

    GridPane.setHalignment(hBox, HPos.LEFT);
    GridPane.setRowIndex(hBox, ++rowIndex);
    GridPane.setColumnSpan(hBox, 2);
    GridPane.setMargin(hBox, new Insets(buttonDistance, 0, 0, 0));
    gridPane.getChildren().add(hBox);
}
 
Example 6
Source File: UpdateWindow.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param window
 * 		Window reference to handle UI access.
 *
 * @return Update popup.
 */
public static UpdateWindow create(MainWindow window) {
	Label lblTitle = new Label(translate("update.outdated"));
	Label lblVersion = new Label(Recaf.VERSION + " → " + SelfUpdater.getLatestVersion());
	Label lblDate = new Label(SelfUpdater.getLatestVersionDate().toString());
	lblTitle.getStyleClass().add("h1");
	lblDate.getStyleClass().add("faint");
	GridPane grid = new GridPane();
	GridPane.setHalignment(lblVersion, HPos.CENTER);
	GridPane.setHalignment(lblDate, HPos.CENTER);
	grid.setPadding(new Insets(15));
	grid.setHgap(10);
	grid.setVgap(10);
	grid.setAlignment(Pos.CENTER);
	grid.add(new Label(translate("update.available")), 0, 0);
	grid.add(new ActionButton(translate("misc.open"), () -> window.getMenubar().showUpdatePrompt()), 1, 0);
	grid.add(lblVersion, 0, 1, 2, 1);
	grid.add(lblDate, 0, 2, 2, 1);
	return new UpdateWindow(grid, lblTitle);
}
 
Example 7
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple2<Label, TextFieldWithCopyIcon> addConfirmationLabelTextFieldWithCopyIcon(GridPane gridPane,
                                                                                             int rowIndex,
                                                                                             String title,
                                                                                             String value,
                                                                                             double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);
    label.getStyleClass().add("confirmation-label");
    GridPane.setHalignment(label, HPos.LEFT);

    TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon("confirmation-text-field-as-label");
    textFieldWithCopyIcon.setText(value);
    GridPane.setRowIndex(textFieldWithCopyIcon, rowIndex);
    GridPane.setColumnIndex(textFieldWithCopyIcon, 1);
    GridPane.setMargin(textFieldWithCopyIcon, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(textFieldWithCopyIcon);

    return new Tuple2<>(label, textFieldWithCopyIcon);
}
 
Example 8
Source File: Exercise_15_05.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create UI
	GridPane pane = new GridPane();
	pane.setVgap(5);
	pane.setHgap(5);
	pane.add(new Label("Investment Amount:"), 0, 0);
	pane.add(tfInvestmentAmount, 1, 0);
	pane.add(new Label("Number Of Years:"), 0, 1);
	pane.add(tfNumberOfYears, 1, 1);
	pane.add(new Label("Annual Interest Rate:"), 0, 2);
	pane.add(tfAnnualInterestRate, 1, 2);
	pane.add(new Label("Future value:"), 0, 3);
	pane.add(tfFutureValue, 1, 3);
	pane.add(btCalculate, 1, 4);

	// Set UI properties
	pane.setAlignment(Pos.CENTER);
	tfInvestmentAmount.setAlignment(Pos.BOTTOM_RIGHT);
	tfNumberOfYears.setAlignment(Pos.BOTTOM_RIGHT);
	tfAnnualInterestRate.setAlignment(Pos.BOTTOM_RIGHT);
	tfFutureValue.setAlignment(Pos.BOTTOM_RIGHT);
	tfFutureValue.setEditable(false);
	pane.setHalignment(btCalculate, HPos.RIGHT);
	pane.setPadding(new Insets(10, 10, 10, 10));

	// Process events
	btCalculate.setOnAction(e -> futureValue());

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_15_05"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 9
Source File: Exercise_14_07.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a GridPane and set its properties
	GridPane pane = new GridPane();
	pane.setPadding(new Insets(5, 5, 5, 5));
	pane.setHgap(5);
	pane.setVgap(5);

	// Place text fields containing a centered, 
	// randomly generated string of 0 or 1 in the pane
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			TextField text = new TextField();
			text.setPrefColumnCount(1);
			text.setText(String.valueOf((int)(Math.random() * 2)));
			pane.add(text, i, j);
			pane.setHalignment(text, HPos.CENTER);
			pane.setValignment(text, VPos.CENTER);
		}
	}

	// Create a scene and plane it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_14_07"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 10
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text, double top, double maxWidth) {
    Label label = new AutoTooltipLabel(text);
    label.setWrapText(true);
    label.setMaxWidth(maxWidth);
    GridPane.setHalignment(label, HPos.LEFT);
    GridPane.setHgrow(label, Priority.ALWAYS);
    GridPane.setRowIndex(label, rowIndex);
    GridPane.setMargin(label, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0));
    gridPane.getChildren().add(label);
    return label;
}
 
Example 11
Source File: AuthenticatedPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void initialize() {

        GridPane.setHalignment(signOutButton, HPos.CENTER);
        authenticatedView.showingProperty().addListener((obs, oldValue, newValue) -> {
            if (newValue) {
                AppBar appBar = getApp().getAppBar();
                appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> 
                        getApp().getDrawer().open()));
                appBar.setTitleText("Authenticated");
                loadDetails();
            }
        });
    }
 
Example 12
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addReportErrorButtons() {
    messageLabel.setText(Res.get("popup.reportError", truncatedMessage));

    Button logButton = new AutoTooltipButton(Res.get("popup.reportError.log"));
    GridPane.setMargin(logButton, new Insets(20, 0, 0, 0));
    GridPane.setHalignment(logButton, HPos.LEFT);
    GridPane.setRowIndex(logButton, ++rowIndex);
    gridPane.getChildren().add(logButton);
    logButton.setOnAction(event -> {
        try {
            File dataDir = Config.appDataDir();
            File logFile = new File(dataDir, "bisq.log");
            Utilities.openFile(logFile);
        } catch (IOException e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
    });

    Button gitHubButton = new AutoTooltipButton(Res.get("popup.reportError.gitHub"));
    GridPane.setHalignment(gitHubButton, HPos.RIGHT);
    GridPane.setRowIndex(gitHubButton, ++rowIndex);
    gridPane.getChildren().add(gitHubButton);
    gitHubButton.setOnAction(event -> {
        if (message != null)
            Utilities.copyToClipboard(message);
        GUIUtil.openWebPage("https://bisq.network/source/bisq/issues");
        hide();
    });
}
 
Example 13
Source File: WebCamWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addContent() {
    GridPane.setHalignment(headLineLabel, HPos.CENTER);

    Label label = FormBuilder.addLabel(gridPane, ++rowIndex, Res.get("account.notifications.waitingForWebCam"));
    label.setAlignment(Pos.CENTER);
    GridPane.setColumnSpan(label, 2);
    GridPane.setHalignment(label, HPos.CENTER);

    GridPane.setRowIndex(imageView, rowIndex);
    GridPane.setColumnSpan(imageView, 2);
    gridPane.getChildren().add(imageView);
}
 
Example 14
Source File: BaseInfoTab.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
protected static Label createTitleLabel(String text) {
    Label ret = new Label(DefaultI18nContext.getInstance().i18n(text) + ":");
    ret.getStyleClass().add("info-property");
    GridPane.setHalignment(ret, HPos.RIGHT);
    GridPane.setValignment(ret, VPos.TOP);
    return ret;
}
 
Example 15
Source File: BlendEffect.java    From Learn-Java-12-Programming with MIT License 5 votes vote down vote up
public void start1(Stage primaryStage) {
    try {
        BlendMode bm1 = BlendMode.MULTIPLY;
        BlendMode bm2 = BlendMode.SRC_OVER;
        Node[] node = setEffectOnGroup(bm1, bm2);
        //Node[] node = setModeOnGroup(bm1, bm2);
        //Node[] node = setEffectOnCircle(bm1, bm2);
        //Node[] node = setEffectOnSquare(bm1, bm2);
        //Node[] node = setModeOnCircle(bm1, bm2);
        //Node[] node = setModeOnSquare(bm1, bm2);

        GridPane grid = new GridPane();
        grid.setAlignment(Pos.CENTER);
        grid.setHgap(40);
        grid.setVgap(15);
        grid.setPadding(new Insets(20, 20, 20, 20));

        int i = 0;
        grid.addRow(i++, new Text("Circle top"), new Text("Square top"));
        grid.add(node[0],    0, i++, 2, 1);
        GridPane.setHalignment(node[0], HPos.CENTER);
        grid.addRow(i++, node[1], node[2]);
        grid.add(node[3],    0, i++, 2, 1);
        GridPane.setHalignment(node[3], HPos.CENTER);
        grid.addRow(i++, node[4], node[5]);
        Text txt = new Text("Circle opacity - 0.5\nSquare opacity - 1.0");
        grid.add(txt,    0, i++, 2, 1);
        GridPane.setHalignment(txt, HPos.CENTER);

        Scene scene = new Scene(grid, 350, 350);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX blend effect");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example 16
Source File: DatePickerSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void initUI() {
    VBox vbox = new VBox(20);
    vbox.setStyle("-fx-padding: 10;");
    Scene scene = new Scene(vbox, 400, 400);
    stage.setScene(scene);

    checkInDatePicker = new DatePicker();
    checkOutDatePicker = new DatePicker();
    checkInDatePicker.setValue(LocalDate.now());

    final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
        @Override
        public DateCell call(final DatePicker datePicker) {
            return new DateCell() {
                @Override
                public void updateItem(LocalDate item, boolean empty) {
                    super.updateItem(item, empty);

                    if (item.isBefore(checkInDatePicker.getValue().plusDays(1))) {
                        setDisable(true);
                        setStyle("-fx-background-color: #ffc0cb;");
                    }
                    long p = ChronoUnit.DAYS.between(checkInDatePicker.getValue(), item);
                    setTooltip(new Tooltip("You're about to stay for " + p + " days"));
                }
            };
        }
    };

    checkOutDatePicker.setDayCellFactory(dayCellFactory);
    checkOutDatePicker.setValue(checkInDatePicker.getValue().plusDays(1));
    checkInDatePicker.setChronology(ThaiBuddhistChronology.INSTANCE);
    checkOutDatePicker.setChronology(HijrahChronology.INSTANCE);

    GridPane gridPane = new GridPane();
    gridPane.setHgap(10);
    gridPane.setVgap(10);

    Label checkInlabel = new Label("Check-In Date:");
    gridPane.add(checkInlabel, 0, 0);
    GridPane.setHalignment(checkInlabel, HPos.LEFT);

    gridPane.add(checkInDatePicker, 0, 1);

    Label checkOutlabel = new Label("Check-Out Date:");
    gridPane.add(checkOutlabel, 0, 2);
    GridPane.setHalignment(checkOutlabel, HPos.LEFT);

    gridPane.add(checkOutDatePicker, 0, 3);

    vbox.getChildren().add(gridPane);

}
 
Example 17
Source File: PatchEditorTab.java    From EWItool with GNU General Public License v3.0 4 votes vote down vote up
GroupLabel( String lab ) {
  setText( lab );
  setId( "editor-group-label" );
  GridPane.setHalignment( this, HPos.CENTER );
}
 
Example 18
Source File: ConstraintsDisplay.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
public void setPropertiesMap(final Map<String, Object> value) {
    getChildren().clear();

    propMap = value;

    if (propMap != null) {
        final Object keys[] = propMap.keySet().toArray();
        int row = 0;
        for (int i = 0; i < keys.length; i++) {
            if (keys[i] instanceof String) {
                final String propkey = (String) keys[i];
                if (propkey.contains("pane-") || propkey.contains("box-")) {
                    final Object keyvalue = propMap.get(propkey);
                    final Label label = new Label(propkey + ":");
                    label.getStyleClass().add("key");
                    GridPane.setConstraints(label, 0, row);
                    GridPane.setValignment(label, VPos.TOP);
                    GridPane.setHalignment(label, HPos.RIGHT);
                    getChildren().add(label);
                    
                    if (propkey.endsWith("margin")) {
                        final InsetsDisplay marginDisplay = new InsetsDisplay();
                        marginDisplay.setInsetsTarget((Insets) keyvalue);
                        GridPane.setConstraints(marginDisplay, 1, row++);
                        GridPane.setHalignment(marginDisplay, HPos.LEFT);
                        getChildren().add(marginDisplay);
                    } else {
                        final Label valueLabel = new Label(keyvalue.toString());
                        valueLabel.getStyleClass().add("value");
                        GridPane.setConstraints(valueLabel, 1, row++);
                        GridPane.setHalignment(valueLabel, HPos.LEFT);
                        getChildren().add(valueLabel);
                    }
                }
            }
        }
    } else {
        final Text novalue = new Text("-");
        GridPane.setConstraints(novalue, 0, 0);
        getChildren().add(novalue);
    }

    // FIXME without this we have ghost text appearing where the layout
    // constraints should be
    if (getChildren().isEmpty()) {
        getChildren().add(new Rectangle(1, 1, Color.TRANSPARENT));
    }

    requestLayout();
}
 
Example 19
Source File: DepositView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void initialize() {

    paymentLabelString = Res.get("funds.deposit.fundBisqWallet");
    addressColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.address")));
    balanceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.balanceWithCur", Res.getBaseCurrencyCode())));
    confirmationsColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.confirmations")));
    usageColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.usage")));

    // trigger creation of at least 1 savings address
    walletService.getFreshAddressEntry();

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    tableView.setPlaceholder(new AutoTooltipLabel(Res.get("funds.deposit.noAddresses")));
    tableViewSelectionListener = (observableValue, oldValue, newValue) -> {
        if (newValue != null) {
            fillForm(newValue.getAddressString());
            GUIUtil.requestFocus(amountTextField);
        }
    };

    setAddressColumnCellFactory();
    setBalanceColumnCellFactory();
    setUsageColumnCellFactory();
    setConfidenceColumnCellFactory();

    addressColumn.setComparator(Comparator.comparing(DepositListItem::getAddressString));
    balanceColumn.setComparator(Comparator.comparing(DepositListItem::getBalanceAsCoin));
    confirmationsColumn.setComparator(Comparator.comparingDouble(o -> o.getTxConfidenceIndicator().getProgress()));
    usageColumn.setComparator(Comparator.comparingInt(DepositListItem::getNumTxOutputs));
    tableView.getSortOrder().add(usageColumn);
    tableView.setItems(sortedList);

    titledGroupBg = addTitledGroupBg(gridPane, gridRow, 4, Res.get("funds.deposit.fundWallet"));
    titledGroupBg.getStyleClass().add("last");

    qrCodeImageView = new ImageView();
    qrCodeImageView.getStyleClass().add("qr-code");
    Tooltip.install(qrCodeImageView, new Tooltip(Res.get("shared.openLargeQRWindow")));
    qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(
            () -> UserThread.runAfter(
                    () -> new QRCodeWindow(getBitcoinURI()).show(),
                    200, TimeUnit.MILLISECONDS)));
    GridPane.setRowIndex(qrCodeImageView, gridRow);
    GridPane.setRowSpan(qrCodeImageView, 4);
    GridPane.setColumnIndex(qrCodeImageView, 1);
    GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 10));
    gridPane.getChildren().add(qrCodeImageView);

    addressTextField = addAddressTextField(gridPane, ++gridRow, Res.get("shared.address"), Layout.FIRST_ROW_DISTANCE);
    addressTextField.setPaymentLabel(paymentLabelString);


    amountTextField = addInputTextField(gridPane, ++gridRow, Res.get("funds.deposit.amount"));
    amountTextField.setMaxWidth(380);
    if (DevEnv.isDevMode())
        amountTextField.setText("10");

    titledGroupBg.setVisible(false);
    titledGroupBg.setManaged(false);
    qrCodeImageView.setVisible(false);
    qrCodeImageView.setManaged(false);
    addressTextField.setVisible(false);
    addressTextField.setManaged(false);
    amountTextField.setManaged(false);

    generateNewAddressButton = addButton(gridPane, ++gridRow, Res.get("funds.deposit.generateAddress"), -20);
    GridPane.setColumnIndex(generateNewAddressButton, 0);
    GridPane.setHalignment(generateNewAddressButton, HPos.LEFT);

    generateNewAddressButton.setOnAction(event -> {
        boolean hasUnUsedAddress = observableList.stream().anyMatch(e -> e.getNumTxOutputs() == 0);
        if (hasUnUsedAddress) {
            new Popup().warning(Res.get("funds.deposit.selectUnused")).show();
        } else {
            AddressEntry newSavingsAddressEntry = walletService.getFreshAddressEntry();
            updateList();
            observableList.stream()
                    .filter(depositListItem -> depositListItem.getAddressString().equals(newSavingsAddressEntry.getAddressString()))
                    .findAny()
                    .ifPresent(depositListItem -> tableView.getSelectionModel().select(depositListItem));
        }
    });

    balanceListener = new BalanceListener() {
        @Override
        public void onBalanceChanged(Coin balance, Transaction tx) {
            updateList();
        }
    };

    GUIUtil.focusWhenAddedToScene(amountTextField);
}
 
Example 20
Source File: WalletPasswordWindow.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void showRestoreScreen() {
    Label headLine2Label = new AutoTooltipLabel(Res.get("seed.restore.title"));
    headLine2Label.getStyleClass().add("popup-headline");
    headLine2Label.setMouseTransparent(true);
    GridPane.setHalignment(headLine2Label, HPos.LEFT);
    GridPane.setRowIndex(headLine2Label, ++rowIndex);
    GridPane.setMargin(headLine2Label, new Insets(30, 0, 0, 0));
    gridPane.getChildren().add(headLine2Label);

    seedWordsTextArea = addTextArea(gridPane, ++rowIndex, Res.get("seed.enterSeedWords"), 5);
    ;
    seedWordsTextArea.setPrefHeight(60);

    Tuple2<Label, DatePicker> labelDatePickerTuple2 = addTopLabelDatePicker(gridPane, ++rowIndex,
            Res.get("seed.creationDate"), 10);
    datePicker = labelDatePickerTuple2.second;
    restoreButton = addPrimaryActionButton(gridPane, ++rowIndex, Res.get("seed.restore"), 0);
    restoreButton.setDefaultButton(true);
    stage.setHeight(570);


    // wallet creation date is not encrypted
    LocalDate walletCreationDate = Instant.ofEpochSecond(walletsManager.getChainSeedCreationTimeSeconds()).atZone(ZoneId.systemDefault()).toLocalDate();
    log.info("walletCreationDate " + walletCreationDate);
    datePicker.setValue(walletCreationDate);
    restoreButton.disableProperty().bind(createBooleanBinding(() -> !seedWordsValid.get() || !seedWordsEdited.get(),
            seedWordsValid, seedWordsEdited));

    seedWordsValidChangeListener = (observable, oldValue, newValue) -> {
        if (newValue) {
            seedWordsTextArea.getStyleClass().remove("validation-error");
        } else {
            seedWordsTextArea.getStyleClass().add("validation-error");
        }
    };

    wordsTextAreaChangeListener = (observable, oldValue, newValue) -> {
        seedWordsEdited.set(true);
        try {
            MnemonicCode codec = new MnemonicCode();
            codec.check(Splitter.on(" ").splitToList(newValue));
            seedWordsValid.set(true);
        } catch (IOException | MnemonicException e) {
            seedWordsValid.set(false);
        }
    };

    seedWordsValid.addListener(seedWordsValidChangeListener);
    seedWordsTextArea.textProperty().addListener(wordsTextAreaChangeListener);
    restoreButton.disableProperty().bind(createBooleanBinding(() -> !seedWordsValid.get() || !seedWordsEdited.get(),
            seedWordsValid, seedWordsEdited));

    restoreButton.setOnAction(e -> onRestore());

    seedWordsTextArea.getStyleClass().remove("validation-error");
    datePicker.getStyleClass().remove("validation-error");

    layout();
}