當前位置: 首頁>>代碼示例>>Java>>正文


Java TextInputDialog類代碼示例

本文整理匯總了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;
}
 
開發者ID:mikelaud,項目名稱:fx-media-tags,代碼行數:24,代碼來源:FxMediaTags.java

示例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);
    }
  });
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:20,代碼來源:StatusBarManager.java

示例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());
    }
}
 
開發者ID:Stevoisiak,項目名稱:Virtual-Game-Shelf,代碼行數:23,代碼來源:MainMenuBar.java

示例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);
		}
	}
	


}
 
開發者ID:ScreachFr,項目名稱:titanium,代碼行數:19,代碼來源:PlayerView.java

示例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();
					}
				});
			}));
		}
	});
}
 
開發者ID:lukasbischof,項目名稱:Orsum-occulendi,代碼行數:26,代碼來源:Controller.java

示例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();
        }
    });
}
 
開發者ID:jdesive,項目名稱:textmd,代碼行數:24,代碼來源:EditorOpenUrlItem.java

示例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();
        }
    });
}
 
開發者ID:jdesive,項目名稱:textmd,代碼行數:22,代碼來源:EditorImportUrlItem.java

示例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();
}
 
開發者ID:Obsidiam,項目名稱:joanne,代碼行數:18,代碼來源:ImageManager.java

示例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;
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:26,代碼來源:Main.java

示例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();
	}
}
 
開發者ID:Bios-Marcel,項目名稱:ServerBrowser,代碼行數:32,代碼來源:GTAController.java

示例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
}
 
開發者ID:Naoghuman,項目名稱:Incubator,代碼行數:17,代碼來源:AudioClipBoxPresenter.java

示例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
}
 
開發者ID:Naoghuman,項目名稱:Incubator,代碼行數:17,代碼來源:TopicPresenter.java

示例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 + ";");
}
 
開發者ID:danielhuson,項目名稱:megan-ce,代碼行數:22,代碼來源:NewAttributeCommand.java

示例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);
	});
}
 
開發者ID:mbway,項目名稱:Simulizer,代碼行數:24,代碼來源:UIUtils.java

示例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);
	});
}
 
開發者ID:mbway,項目名稱:Simulizer,代碼行數:24,代碼來源:UIUtils.java


注:本文中的javafx.scene.control.TextInputDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。