javafx.scene.control.TextInputDialog#setTitle ( )源码实例Demo

下面列出了javafx.scene.control.TextInputDialog#setTitle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: constellation   文件: JsonIODialog.java
/**
 * Displays a small window allowing the user to enter a name for the new
 * preference
 *
 * @author formalhaut69
 * @return A tuple, the first item is a Boolean indicating whether the user
 * selected to proceed with the operation or not, the second is the name of
 * the file requested by the user.
 */
public static Tuple<Boolean, String> getName() {
    String returnedName = "";

    // opens up a slightly different dialog window to allow the user to name the
    // preference when it is being saved
    // create a text input dialog 
    TextInputDialog td = new TextInputDialog();
    td.setTitle("Preference name");
    // setHeaderText 
    td.setHeaderText("Enter a name for the preference");
    Optional<String> result = td.showAndWait();
    if (result.isPresent()) {
        returnedName = td.getEditor().getText();
    }
    return new Tuple<>(result.isPresent(), returnedName);
}
 
源代码2 项目: tcMenu   文件: ArduinoLibraryInstaller.java
/**
 * This method will be called internally by the above method when a non standard layout is detected.
 *
 * @return the arduino path wrapped in an optional, or nothing if cancel is pressed.
 */
private Optional<String> getArduinoPathWithDialog() {
    String savedPath = Preferences.userNodeForPackage(ArduinoLibraryInstaller.class)
            .get(ARDUINO_CUSTOM_PATH, homeDirectory);

    Path libsPath = Paths.get(savedPath, "libraries");
    if (Files.exists(libsPath)) return Optional.of(savedPath);

    TextInputDialog dialog = new TextInputDialog(savedPath);
    dialog.setTitle("Manually enter Arduino Path");
    dialog.setHeaderText("Please manually enter the full path to the Arduino folder");
    dialog.setContentText("Arduino Path");
    Optional<String> path = dialog.showAndWait();
    path.ifPresent((p) -> Preferences.userNodeForPackage(ArduinoLibraryInstaller.class).put(ARDUINO_CUSTOM_PATH, p));
    return path;
}
 
源代码3 项目: megan-ce   文件: NewAttributeCommand.java
public void actionPerformed(ActionEvent event) {
    final SamplesViewer viewer = ((SamplesViewer) getViewer());
    final int index;
    final String selectedAttribute = viewer.getSamplesTableView().getASelectedAttribute();
    if (selectedAttribute != null)
        index = viewer.getSamplesTableView().getAttributes().indexOf(selectedAttribute);
    else
        index = viewer.getSamplesTableView().getSampleCount();

    String name = null;
    if (Platform.isFxApplicationThread()) {
        TextInputDialog dialog = new TextInputDialog("Attribute");
        dialog.setTitle("New attribute");
        dialog.setHeaderText("Enter attribute name:");

        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            name = result.get().trim();
        }
    } else if (javax.swing.SwingUtilities.isEventDispatchThread()) {
        name = JOptionPane.showInputDialog(getViewer().getFrame(), "Enter new attribute name", "Untitled");
    }

    if (name != null)
        executeImmediately("new attribute='" + name + "' position=" + index + ";");
}
 
源代码4 项目: MyBox   文件: DownloadController.java
@FXML
protected void plusAction() {
    try {
        TextInputDialog dialog = new TextInputDialog("https://");
        dialog.setTitle(message("DownloadManage"));
        dialog.setHeaderText(message("InputAddress"));
        dialog.setContentText("");
        dialog.getEditor().setPrefWidth(500);
        Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();
        Optional<String> result = dialog.showAndWait();
        if (!result.isPresent()) {
            return;
        }
        String address = result.get();
        download(address);

    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
源代码5 项目: MyBox   文件: MyBoxLanguagesController.java
@FXML
public void plusAction() {
    TextInputDialog dialog = new TextInputDialog("");
    dialog.setTitle(message("ManageLanguages"));
    dialog.setHeaderText(message("InputLangaugeName"));
    dialog.setContentText("");
    dialog.getEditor().setPrefWidth(200);
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();

    Optional<String> result = dialog.showAndWait();
    if (!result.isPresent() || result.get().trim().isBlank()) {
        return;
    }
    langName = result.get().trim();
    langLabel.setText(langName);
    loadLanguage(null);
}
 
源代码6 项目: PeerWasp   文件: Network.java
@FXML
public void editAction(ActionEvent event) {
	// load current selection and allow user to change value
	int index = lwBootstrappingNodes.getSelectionModel().getSelectedIndex();
	String nodeAddress = lwBootstrappingNodes.getSelectionModel().getSelectedItem();

	TextInputDialog input = new TextInputDialog();
	DialogUtils.decorateDialogWithIcon(input);
	input.getEditor().setText(nodeAddress);
	input.setTitle("Edit Node Address");
	input.setHeaderText("Enter node address");
	Optional<String> result = input.showAndWait();

	if(result.isPresent()) {
		String newNodeAddress = result.get().trim();
		if (!newNodeAddress.isEmpty() && !containsAddress(newNodeAddress)) {
			addresses.add(index, newNodeAddress);
			addresses.remove(nodeAddress);
		}
	}
}
 
源代码7 项目: megan-ce   文件: Dialogs.java
/**
 * show an input dialog
 *
 * @param swingParent
 * @param title
 * @param message
 * @param initialValue
 * @return
 */
private static String showInput(final Component swingParent, final String title, final String message, final String initialValue) {
    final Single<String> input = new Single<>(null);

    if (Platform.isFxApplicationThread()) {
        final TextInputDialog dialog = new TextInputDialog(initialValue != null ? initialValue : "");
        dialog.setTitle(title);
        dialog.setHeaderText(message);

        final Optional<String> result = dialog.showAndWait();
        result.ifPresent(input::set);

    } else if (javax.swing.SwingUtilities.isEventDispatchThread()) {
        input.set(JOptionPane.showInputDialog(swingParent, message, initialValue));
    } else {
        try {
            SwingUtilities.invokeAndWait(() -> input.set(showInput(swingParent, title, message, initialValue)));
        } catch (Exception e) {
            Basic.caught(e);
        }
    }
    return input.get();
}
 
源代码8 项目: pcgen   文件: PCGenFrame.java
@Override
public Optional<String> showInputDialog(String title, String message, String initialValue)
{
	GuiAssertions.assertIsNotJavaFXThread();
	TextInputDialog dialog = GuiUtility.runOnJavaFXThreadNow(() -> new TextInputDialog(initialValue));
	dialog.setTitle(title);
	dialog.setContentText(message);
	return GuiUtility.runOnJavaFXThreadNow(dialog::showAndWait);
}
 
源代码9 项目: MyBox   文件: MediaListController.java
@FXML
@Override
public void saveAsAction() {
    MediaList selected = tableView.getSelectionModel().getSelectedItem();
    if (selected == null || selected.getMedias() == null) {
        return;
    }
    TextInputDialog dialog = new TextInputDialog("");
    dialog.setTitle(message("ManageMediaLists"));
    dialog.setHeaderText(message("InputMediaListName"));
    dialog.setContentText("");
    dialog.getEditor().setPrefWidth(400);
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();
    Optional<String> result = dialog.showAndWait();
    if (!result.isPresent() || result.get().trim().isBlank()) {
        return;
    }
    String newName = result.get().trim();
    for (MediaList list : tableData) {
        if (list.getName().equals(newName)) {
            popError(message("AlreadyExisted"));
            return;
        }
    }
    if (TableMediaList.set(newName, selected.getMedias())) {
        popSuccessful();
        tableData.add(MediaList.create().setName(newName).setMedias(selected.getMedias()));
    } else {
        popFailed();
    }

}
 
源代码10 项目: megan-ce   文件: RenameSampleCommand.java
public void actionPerformed(ActionEvent event) {
    SamplesViewer viewer = (SamplesViewer) getViewer();
    String sampleName = viewer.getSamplesTableView().getASelectedSample();
    String newName = null;
    if (Platform.isFxApplicationThread()) {
        TextInputDialog dialog = new TextInputDialog(sampleName);
        dialog.setTitle("Rename sample");
        dialog.setHeaderText("Enter new sample name:");

        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            newName = result.get().trim();
        }
    } else if (javax.swing.SwingUtilities.isEventDispatchThread()) {
        newName = JOptionPane.showInputDialog(getViewer().getFrame(), "Enter new sample name", sampleName);
    }

    if (newName != null && !newName.equals(sampleName)) {
        if (viewer.getSampleAttributeTable().getSampleOrder().contains(newName)) {
            int count = 1;
            while (viewer.getSampleAttributeTable().getSampleOrder().contains(newName + "." + count))
                count++;
            newName += "." + count;
        }
        execute("rename sample='" + sampleName + "' newName='" + newName + "';" +
                "labelBy attribute='" + SampleAttributeTable.SAMPLE_ID + "'  samples=all;");
    }
}
 
源代码11 项目: MyBox   文件: MediaTableController.java
@FXML
@Override
public void saveAction() {
    if (mediaListName == null || mediaListName.isBlank()) {
        if (tableData.isEmpty()) {
            tableLabel.setText("");
            return;
        }
        TextInputDialog dialog = new TextInputDialog("");
        dialog.setTitle(message("ManageMediaLists"));
        dialog.setHeaderText(message("InputMediaListName"));
        dialog.setContentText("");
        dialog.getEditor().setPrefWidth(400);
        Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();

        Optional<String> result = dialog.showAndWait();
        if (!result.isPresent() || result.get().trim().isBlank()) {
            return;
        }
        mediaListName = result.get().trim();
    }
    if (TableMediaList.set(mediaListName, tableData)) {
        tableLabel.setText(message("MediaList") + ": " + mediaListName);
        if (parentController != null) {
            parentController.popSuccessful();
            if (parentController instanceof MediaListController) {
                ((MediaListController) parentController).update(mediaListName);
            }
        }
    } else {
        if (parentController != null) {
            parentController.popFailed();
        }
    }
}
 
源代码12 项目: marathonv5   文件: CheckListView.java
public void onHeader() {
    TextInputDialog input = new TextInputDialog();
    input.setTitle("New Header");
    input.setContentText("Label: ");
    input.setHeaderText("Please enter header text.");
    Optional<String> result = input.showAndWait();
    result.ifPresent(name -> {
        checkListFormNode.addHeader(name);
        fireContentChanged();
    });
}
 
源代码13 项目: marathonv5   文件: CheckListView.java
public void onChecklist() {
    TextInputDialog input = new TextInputDialog();
    input.setTitle("New Checklist Item");
    input.setContentText("Label: ");
    input.setHeaderText("Please enter item label.");
    Optional<String> result = input.showAndWait();
    result.ifPresent(name -> {
        checkListFormNode.addCheckListItem(name);
        fireContentChanged();
    });
}
 
源代码14 项目: marathonv5   文件: CheckListView.java
public void onTextArea() {
    TextInputDialog input = new TextInputDialog();
    input.setTitle("New Textbox");
    input.setContentText("Label: ");
    input.setHeaderText("Please enter text box label.");
    Optional<String> result = input.showAndWait();
    result.ifPresent(name -> {
        checkListFormNode.addTextArea(name);
        fireContentChanged();
    });
}
 
源代码15 项目: logbook-kai   文件: FleetTabPane.java
/**
 * 分岐点係数を変更する
 *
 * @param event ActionEvent
 */
@FXML
void changeBranchCoefficient(ActionEvent event) {
    TextInputDialog dialog = new TextInputDialog(Double.toString(this.branchCoefficient));
    dialog.getDialogPane().getStylesheets().add("logbook/gui/application.css");
    InternalFXMLLoader.setGlobal(dialog.getDialogPane());
    dialog.initOwner(this.getScene().getWindow());
    dialog.setTitle("分岐点係数を変更");
    dialog.setHeaderText("分岐点係数を数値で入力してください 例)\n"
            + "沖ノ島沖 G,I,Jマス 係数: 1.0\n"
            + "北方AL海域 Gマス 係数: 4.0\n"
            + "中部海域哨戒線 G,Hマス 係数: 4.0\n"
            + "MS諸島沖 E,Iマス 係数: 3.0\n"
            + "グアノ環礁沖海域 Hマス 係数: 3.0");

    val result = dialog.showAndWait();
    if (result.isPresent()) {
        String value = result.get();
        if (!value.isEmpty()) {
            try {
                this.branchCoefficient = Double.parseDouble(value);
                this.setDecision33();
            } catch (NumberFormatException e) {
            }
        }
    }
}
 
源代码16 项目: java-ml-projects   文件: AppUtils.java
public static Optional<String> askInputFromUser(String title, String msg) {
	TextInputDialog dialog = new TextInputDialog();
	dialog.setTitle(title);
	dialog.setHeaderText(null);
	dialog.setContentText(msg);
	return dialog.showAndWait();
}
 
源代码17 项目: phoebus   文件: SaveLayoutMenuItem.java
/** Save the layout. Prompt for a new filename, validate, possibly confirm an overwrite, and then save.
 *  @return <code>true</code> if layout save has been initiated (may take some time to complete)
 */
private boolean saveLayout()
{
    final TextInputDialog prompt = new TextInputDialog();
    prompt.setTitle(getText());
    prompt.setHeaderText(Messages.SaveDlgHdr);
    positionDialog(prompt);

    while (true)
    {
        final String filename = prompt.showAndWait().orElse(null);

        // Canceled?
        if (filename == null)
            return false;
        // OK to save?
        if (! validateFilename(filename))
        {
            // Ask again
            prompt.setHeaderText(Messages.SaveDlgErrHdr);
            continue;
        }
        else
            prompt.setHeaderText(Messages.SaveDlgHdr);

        // Done if save succeeded.
        if (saveState(filename))
            return true;
    }
}
 
源代码18 项目: qiniu   文件: DialogUtils.java
public static String showInputDialog(String header, String content, String defaultValue) {
    TextInputDialog dialog = new TextInputDialog(defaultValue);
    dialog.setTitle(QiniuValueConsts.MAIN_TITLE);
    dialog.setHeaderText(header);
    dialog.setContentText(content);
    Optional<String> result = dialog.showAndWait();
    return result.orElse(null);
}
 
@FXML
@Override
public void addAction() {
    try {
        TextInputDialog dialog = new TextInputDialog("docs.oracle.com");
        dialog.setTitle(message("SSLVerificationByPass"));
        dialog.setHeaderText(message("InputAddress"));
        dialog.setContentText("");
        dialog.getEditor().setPrefWidth(500);
        Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();

        Optional<String> result = dialog.showAndWait();
        if (!result.isPresent()) {
            return;
        }
        String address = result.get().trim();
        if (address.isBlank()) {
            return;
        }
        for (CertificateBypass p : tableData) {
            if (p.getHost().equals(address)) {
                return;
            }
        }
        if (TableBrowserBypassSSL.write(address)) {
            CertificateBypass newdata = TableBrowserBypassSSL.read(address);
            if (newdata != null) {
                tableData.add(newdata);
                tableView.refresh();
                popSuccessful();
            } else {
                popFailed();
            }
        } else {
            popFailed();
        }

    } catch (Exception e) {
        logger.error(e.toString());
    }

}
 
源代码20 项目: MyBox   文件: SecurityCertificatesAddController.java
@FXML
@Override
public void okAction() {
    if (certController == null) {
        return;
    }
    if (addressRadio.isSelected()) {
        if (addressInput.getText().isEmpty()) {
            popError(message("NotExist"));
            return;
        }
    } else {
        sourceFile = new File(sourceFileInput.getText());
        if (!sourceFile.exists() || !sourceFile.isFile()) {
            popError(message("NotExist"));
            return;
        }
    }

    File ksFile = new File(certController.getSourceFileInput().getText());
    if (!ksFile.exists() || !ksFile.isFile()) {
        popError(message("NotExist"));
        return;
    }
    String password = certController.getPasswordInput().getText();

    TextInputDialog dialog = new TextInputDialog("");
    dialog.setTitle(message("SecurityCertificates"));
    dialog.setHeaderText(message("Alias"));
    dialog.setContentText("");
    dialog.getEditor().setPrefWidth(300);
    Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
    stage.setAlwaysOnTop(true);
    stage.toFront();
    Optional<String> result = dialog.showAndWait();
    if (!result.isPresent() || result.get().trim().isBlank()) {
        return;
    }
    final String alias = result.get().trim();
    if (!certController.backupKeyStore()) {
        return;
    }
    try {
        synchronized (this) {
            if (task != null) {
                return;
            }
            task = new SingletonTask<Void>() {

                @Override
                protected boolean handle() {
                    error = null;

                    if (addressRadio.isSelected()) {
                        try {
                            error = NetworkTools.installCertificateByHost(
                                    ksFile.getAbsolutePath(), password,
                                    addressInput.getText(), alias);
                        } catch (Exception e) {
                            error = e.toString();
                        }
                    } else if (fileRadio.isSelected()) {
                        try {
                            error = NetworkTools.installCertificateByFile(
                                    ksFile.getAbsolutePath(), password,
                                    sourceFile, alias);
                        } catch (Exception e) {
                            error = e.toString();
                        }
                    }
                    return true;
                }

                @Override
                protected void whenSucceeded() {
                    if (error == null) {
                        certController.loadAll(alias);
                        if (saveCloseCheck.isSelected()) {
                            closeStage();
                        }
                        popSuccessful();
                    } else {
                        popError(error);
                    }
                }
            };
            openHandlingStage(task, Modality.WINDOW_MODAL);
            Thread thread = new Thread(task);
            thread.setDaemon(true);
            thread.start();
        }

    } catch (Exception e) {
        logger.error(e.toString());
    }
}