本文整理汇总了Java中javafx.scene.control.TextInputDialog类的典型用法代码示例。如果您正苦于以下问题:Java TextInputDialog类的具体用法?Java TextInputDialog怎么用?Java TextInputDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextInputDialog类属于javafx.scene.control包,在下文中一共展示了TextInputDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMenuAdd
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
private MenuItem createMenuAdd() {
final MenuItem menuAdd = new MenuItem("Add");
menuAdd.setOnAction(event -> {
final TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Custom Tag Input Dialog");
dialog.setHeaderText("New Custom Tag");
dialog.setContentText("Name:");
final Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
final String tagName = StringType.nvl(result.get());
if (!tagName.isEmpty()) {
if (MODEL.tagsProperty().filtered(t -> tagName.equals(t.getName())).isEmpty()) {
final MetaTagModel metaTagModel = new MetaTagModel(tagName);
if (null != MODEL.getOnAddTag()) {
MODEL.getOnAddTag().accept(metaTagModel);
}
MODEL.tagsProperty().add(metaTagModel);
}
}
}
});
return menuAdd;
}
示例2: showLineJumpDialog
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
private void showLineJumpDialog() {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Goto Line");
dialog.getDialogPane().setContentText("Input Line Number: ");
dialog.initOwner(area.getValue().getScene().getWindow());
TextField tf = dialog.getEditor();
int lines = StringUtil.countLine(area.getValue().getText());
ValidationSupport vs = new ValidationSupport();
vs.registerValidator(tf, Validator.<String> createPredicateValidator(
s -> TaskUtil.uncatch(() -> MathUtil.inRange(Integer.valueOf(s), 1, lines)) == Boolean.TRUE,
String.format("Line number must be in [%d,%d]", 1, lines)));
dialog.showAndWait().ifPresent(s -> {
if (vs.isInvalid() == false) {
area.getValue().moveTo(Integer.valueOf(s) - 1, 0);
}
});
}
示例3: onTestImportSteamLibraryXML
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
/** Test importing games into gamelist from Steam library (.xml file). */
public static void onTestImportSteamLibraryXML() {
// TODO: ID field should be empty by default in final code.
// Leaving 'Stevoisiak' as default ID for testing.
// TODO: Accept multiple formats for Steam ID.
// (ie: gabelogannewell, 76561197960287930, STEAM_0:0:11101,
// [U:1:22202], http://steamcommunity.com/id/gabelogannewell/,
// http://steamcommunity.com/profiles/76561197960287930/,
// http://steamcommunity.com/profiles/[U:1:22202]/)
// Convert types with (https://github.com/xPaw/SteamID.php)?
TextInputDialog steamIdDialog = new TextInputDialog("Stevoisiak");
steamIdDialog.setTitle("Import library from Steam");
steamIdDialog.setHeaderText(null);
steamIdDialog.setContentText("Please enter your steam ID.");
Optional<String> steamID = steamIdDialog.showAndWait();
if (steamID.isPresent()) {
SteamCommunityGameImporter importer = new SteamCommunityGameImporter();
importer.steamCommunityAddGames(steamID.get());
}
}
示例4: kickPlayerAction
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
private void kickPlayerAction(ActionEvent e) {
TextInputDialog dial = new TextInputDialog("No reason indicated");
dial.setTitle("Kick player");
dial.setHeaderText("Do you really want to kick " + player.getName() + " ?");
dial.setContentText("Reason ");
Optional<String> result = dial.showAndWait();
if (result.isPresent()) {
try {
server.kickPlayer(player, result.orElse("No reason indicated"));
} catch (RCONServerException e1) {
server.logError(e1);
}
}
}
示例5: presentNewGameProposalWindow
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
@FXML
public void presentNewGameProposalWindow(Event e) {
TextInputDialog dialog = new TextInputDialog();
dialog.setHeaderText("Neuer Spielvorschalg");
dialog.setContentText("Wie soll das Spiel heissen?");
Optional<String> gameNameResult = dialog.showAndWait();
gameNameResult.ifPresent(result -> {
if (!gameNameResult.get().isEmpty()) {
this.client.enqueueTask(new CommunicationTask(new ClientMessage("server", "newgame", gameNameResult.get()), (success, response) -> {
Platform.runLater(() -> {
if (success && response.getDomain().equals("success") && response.getCommand().equals("created")) {
refreshGameList(e);
System.out.println("Game erstellt");
} else {
Alert alert = new Alert(AlertType.ERROR);
alert.setHeaderText("Das Spiel konnte nicht erstellt werden");
alert.setContentText(response.toString());
alert.show();
}
});
}));
}
});
}
示例6: getClickAction
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
@Override
public void getClickAction(final Dictionary dictionary, final Stage stage, final TabFactory tabFactory, final DialogFactory dialogFactory) {
TextInputDialog input = dialogFactory.buildEnterUrlDialogBox(
dictionary.DIALOG_OPEN_URL_TITLE,
dictionary.DIALOG_OPEN_URL_CONTENT
);
Optional<String> result = input.showAndWait();
result.ifPresent(url -> {
try {
tabFactory.createAndAddNewEditorTab(
new File(Utils.getDefaultFileName()),
Http.request(url + "", null, null, null, "GET")
);
} catch (IOException e1) {
dialogFactory.buildExceptionDialogBox(
dictionary.DIALOG_EXCEPTION_TITLE,
dictionary.DIALOG_EXCEPTION_OPENING_MARKDOWN_URL_CONTENT,
e1.getMessage(),
e1
).showAndWait();
}
});
}
示例7: getClickAction
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
@Override
public void getClickAction(final Dictionary dictionary, final TabFactory tabFactory, final DialogFactory dialogFactory) {
TextInputDialog input = dialogFactory.buildEnterUrlDialogBox(
dictionary.DIALOG_IMPORT_URL_TITLE,
dictionary.DIALOG_IMPORT_URL_CONTENT
);
Optional<String> result = input.showAndWait();
result.ifPresent(url -> {
try {
EditorTab tab = ((EditorTab)tabFactory.getSelectedTab());
tab.getEditorPane().setContent(tab.getEditorPane().getContent() + "\n" + Http.request(url + "", null, null, null, "GET"));
} catch (IOException e1) {
dialogFactory.buildExceptionDialogBox(
dictionary.DIALOG_EXCEPTION_TITLE,
dictionary.DIALOG_EXCEPTION_IMPORT_CONTENT,
e1.getMessage(),
e1
).showAndWait();
}
});
}
示例8: renameImage
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
public void renameImage(String path,String file_to_rename) {
TextInputDialog input = new TextInputDialog(file_to_rename.substring(0, file_to_rename.length()-4)+"1"+file_to_rename.substring(file_to_rename.length()-4));
Optional<String> change = input.showAndWait();
change.ifPresent((String change_event) -> {
try {
Files.move(new File(path).toPath(),new File(new File(path).getParent()+File.separator+change_event).toPath());
} catch (IOException ex) {
Alert a = new Alert(AlertType.ERROR);
a.setTitle("Rename");
a.setHeaderText("Error while renaming the file.");
a.setContentText("Error code: "+e.getErrorInfo(ex)+"\n"+e.getErrorMessage(ex));
a.showAndWait();
}
});
System.gc();
}
示例9: renameProject
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
private boolean renameProject(Project project)
{
TextInputDialog dialog = new TextInputDialog(project.getName());
dialog.setTitle("Rename Project");
dialog.setHeaderText(null);
dialog.setGraphic(null);
dialog.setContentText("Enter a new name for the project:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent())
{
String newName = result.get();
if (newName.equals(project.getName()))
{
showInfoDialogue("The new name must be different from the old name");
return renameProject(project);
}
else
{
project.setName(newName);
}
}
return false;
}
示例10: tryToConnect
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
/**
* Connects to a server, depending on if it is passworded, the user will be
* asked to enter a
* password. If the server is not reachable the user can not connect.
*
* @param address
* server address
* @param port
* server port
*/
public static void tryToConnect(final String address, final Integer port) {
try (final SampQuery query = new SampQuery(address, port)) {
final Optional<String[]> serverInfo = query.getBasicServerInfo();
if (serverInfo.isPresent() && StringUtility.stringToBoolean(serverInfo.get()[0])) {
final TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("Connect to Server");
dialog.setHeaderText("Enter the servers password (Leave empty if u think there is none).");
final Optional<String> result = dialog.showAndWait();
result.ifPresent(password -> GTAController.connectToServer(address, port, password));
}
else {
GTAController.connectToServer(address, port, "");
}
}
catch (final IOException exception) {
Logging.warn("Couldn't connect to server.", exception);
showCantConnectToServerError();
}
}
示例11: onMouseClickedChangeTitle
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
private void onMouseClickedChangeTitle() {
LoggerFacade.getDefault().debug(this.getClass(), "On mouse clicked change Title"); // NOI18N
final TextInputDialog dialog = new TextInputDialog(lTitle.getText());
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setHeaderText("Change title"); // NOI18N
dialog.setResizable(Boolean.FALSE);
dialog.setTitle("AudioClip"); // NOI18N
final Optional<String> result = dialog.showAndWait();
if (result.isPresent() && !result.get().isEmpty()) {
lTitle.setText(result.get());
}
// TODO save to db
}
示例12: onMouseClickedChangeTitle
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
private void onMouseClickedChangeTitle() {
LoggerFacade.getDefault().debug(this.getClass(), "On mouse clicked change Title"); // NOI18N
final TextInputDialog dialog = new TextInputDialog(lTitle.getText());
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setHeaderText("Change title"); // NOI18N
dialog.setResizable(Boolean.FALSE);
dialog.setTitle("Topic"); // NOI18N
final Optional<String> result = dialog.showAndWait();
if (result.isPresent() && !result.get().isEmpty()) {
lTitle.setText(result.get());
}
// TODO save to db
}
示例13: actionPerformed
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
public void actionPerformed(ActionEvent event) {
final SamplesViewer viewer = ((SamplesViewer) getViewer());
int position = viewer.getSamplesTable().getASelectedColumnIndex();
String name = null;
if (position != -1) {
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)
execute("new attribute='" + name + "' position=" + position + ";");
}
示例14: openIntInputDialog
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
/**
* show a dialog box to input an integer
*/
public static void openIntInputDialog(String title, String header, String message, int defaultVal, Consumer<Integer> callback) {
TextInputDialog dialog = new TextInputDialog(""+defaultVal);
Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
if(parent != null && parent.getOwner() != null) {
dialog.initOwner(parent.getOwner());
}
dialog.setTitle(title);
dialog.setHeaderText(header);
dialog.setContentText(message);
dialog.showAndWait().ifPresent((text) -> {
int val = defaultVal;
try {
val = Integer.parseInt(text);
} catch(NumberFormatException ignored) {
}
callback.accept(val);
});
}
示例15: openDoubleInputDialog
import javafx.scene.control.TextInputDialog; //导入依赖的package包/类
/**
* show a dialog box to input a double
*/
public static void openDoubleInputDialog(String title, String header, String message, double defaultVal, Consumer<Double> callback) {
TextInputDialog dialog = new TextInputDialog(""+defaultVal);
Stage parent = GuiMode.getPrimaryStage(); // owner is null if JavaFX not fully loaded yet
if(parent != null && parent.getOwner() != null) {
dialog.initOwner(parent.getOwner());
}
dialog.setTitle(title);
dialog.setHeaderText(header);
dialog.setContentText(message);
dialog.showAndWait().ifPresent((text) -> {
double val = defaultVal;
try {
val = Double.parseDouble(text);
} catch(NumberFormatException ignored) {
}
callback.accept(val);
});
}