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


Java TextInputDialog.showAndWait方法代碼示例

本文整理匯總了Java中javafx.scene.control.TextInputDialog.showAndWait方法的典型用法代碼示例。如果您正苦於以下問題:Java TextInputDialog.showAndWait方法的具體用法?Java TextInputDialog.showAndWait怎麽用?Java TextInputDialog.showAndWait使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.TextInputDialog的用法示例。


在下文中一共展示了TextInputDialog.showAndWait方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: telaQuantidade

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
 * M�TODO QUE ABRE A TELA PARA INSERIR A QUANTIDADE DE PRODUTOS PARA ATENDER A ENCOMENDA
 * @return Quantidade de produtos para atender a encomenda
 */
public Integer telaQuantidade(){
	TextInputDialog dialog = new TextInputDialog();
	dialog.setTitle("BuyMe");
	dialog.setHeaderText("Atender encomenda");
	dialog.setContentText("Digite a quantidade que deseja atender com essa produ��o: ");

	Optional<String> result = dialog.showAndWait();
	if (result.isPresent()){
		if(Utils.isNumber(result.get())){
			return Integer.parseInt(result.get());
		}else{
			popup.getError("A quantidade deve ser um n�mero!");
	        
	        return 0;
		}
	}else{
		return 0;
	}
}
 
開發者ID:juan0101,項目名稱:TG-BUYME,代碼行數:24,代碼來源:AtenderEncomendaController.java

示例10: doRename

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
private void doRename() {
    ObservableList<TreeItem<File>> selectedItems = fileTree.getSelectionModel().getSelectedItems();
    if (selectedItems.isEmpty())
        return;
    TreeItem<File> itemSelect = selectedItems.get(0);
    if (itemSelect == null || itemSelect.getValue() == null) {
        return;
    }
    TextInputDialog dialog = new TextInputDialog(itemSelect.getValue().getName());
    dialog.setTitle(Manager.getRes(ResConstants.ALERT_RENAME_TITLE));
    dialog.setHeaderText(Manager.getRes(ResConstants.ALERT_RENAME_HEADER
            , new Object[] {itemSelect.getValue().getName()}));
    Optional<String> result = dialog.showAndWait();
    result.ifPresent(name -> {
        if (name == null || name.trim().isEmpty()) {
            return;
        }
        File file = itemSelect.getValue();
        File newFile = new File(file.getParent(), name);
        file.renameTo(newFile);
        itemSelect.setValue(newFile);
    });
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:24,代碼來源:RenameMenuItem.java

示例11: showTextInput

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
 * Shows a simple dialog that waits for the user to enter some text.
 * @param message The message is shown in the content text of the dialog.
 * @return The user input
    */
private String showTextInput(String message) {
	TextInputDialog dialog = new TextInputDialog();
	((Stage)dialog.getDialogPane().getScene().getWindow()).getIcons().add(new Image("file:pictures/icon.png"));
	dialog.setTitle("Please input a value");
	dialog.setHeaderText(null);
	dialog.setContentText(message);

	Optional<String> input = dialog.showAndWait();
	if (input.isPresent()) {
		if (!input.get().isEmpty()) {
			return input.get();
		} else {
			new TDDTDialog("alert", "Missing input");
		}
	}
	return "-1";
}
 
開發者ID:ProPra16,項目名稱:programmierpraktikum-abschlussprojekt-nimmdochirgendeinennamen,代碼行數:23,代碼來源:TDDTDialog.java

示例12: dropOnSourcePallet

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
private void dropOnSourcePallet(DragEvent event, int sourcePalletId) {
	event.setDropCompleted(true);
	TextInputDialog addBlocksDialog = new TextInputDialog();
	addBlocksDialog.setTitle("Add Blocks");
	addBlocksDialog.setHeaderText("Enter the amount of blocks you want to add");
	Optional<String> result = addBlocksDialog.showAndWait();
	result.ifPresent(count -> sourcePallets[sourcePalletId] += Integer.parseInt(count));
	
	String stateImagePath;
	if (sourcePallets[sourcePalletId] <= 5) {
		stateImagePath = "images/blocks-almost-empty.png";
	} else if (sourcePallets[sourcePalletId] > 5 && sourcePallets[sourcePalletId] <= 15) {
		stateImagePath = "images/blocks-normal.png";
	} else if (sourcePallets[sourcePalletId] > 15) {
		stateImagePath = "images/blocks-full.png";
	} else {
		stateImagePath = "";
	}
	Image stateImage = new Image(getClass().getResource(stateImagePath).toString());
	((BorderPane) event.getSource()).setCenter(new ImageView(stateImage));
	
	System.out.println(Arrays.toString(sourcePallets));
	event.consume();
}
 
開發者ID:gseteamproject,項目名稱:gseproject,代碼行數:25,代碼來源:TrackManagerController.java

示例13: askNameFX

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
 * Ask for a new building name using TextInputDialog in JavaFX/8
 * @return new name
 */
public String askNameFX(String oldName) {
	String newName = null;
	TextInputDialog dialog = new TextInputDialog(oldName);
	dialog.setTitle(Msg.getString("BuildingPanel.renameBuilding.dialogTitle"));
	dialog.setHeaderText(Msg.getString("BuildingPanel.renameBuilding.dialog.header"));
	dialog.setContentText(Msg.getString("BuildingPanel.renameBuilding.dialog.content"));

	Optional<String> result = dialog.showAndWait();
	//result.ifPresent(name -> {});

	if (result.isPresent()){
	    logger.info("The old building name has been changed to: " + result.get());
		newName = result.get();
	}

	return newName;
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:22,代碼來源:BuildingPanel.java

示例14: askNameFX

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
/**
 * Ask for a new building name using TextInputDialog in JavaFX/8
 * @return new name
 */
public String askNameFX(String oldName) {
	String newName = null;
	TextInputDialog dialog = new TextInputDialog(oldName);
	dialog.initOwner(desktop.getMainScene().getStage());
	dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setTitle(Msg.getString("BuildingPanel.renameBuilding.dialogTitle"));
	dialog.setHeaderText(Msg.getString("BuildingPanel.renameBuilding.dialog.header"));
	dialog.setContentText(Msg.getString("BuildingPanel.renameBuilding.dialog.content"));

	Optional<String> result = dialog.showAndWait();
	//result.ifPresent(name -> {});

	if (result.isPresent()){
	    //logger.info("The settlement name has been changed to : " + result.get());
		newName = result.get();
	}

	return newName;
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:24,代碼來源:SettlementTransparentPanel.java

示例15: editValue

import javafx.scene.control.TextInputDialog; //導入方法依賴的package包/類
public void editValue(Optional<String> startValue) {
    TextInputDialog dialog = new TextInputDialog(startValue.orElse(this.getValue()));
    dialog.setTitle("Edit constant block");
    dialog.setHeaderText("Type a Haskell expression");

    Optional<String> result = dialog.showAndWait();

    result.ifPresent(value -> {
        this.setValue(value);
        GhciSession ghci = this.getToplevel().getGhciSession();

        try {
            Type type = ghci.pullType(value, this.getToplevel().getEnvInstance());
            this.output.setExactRequiredType(type);
            this.hasValidValue = true;
            this.outputSpace.setVisible(true);
        } catch (HaskellException e) {
            this.hasValidValue = false;
            this.outputSpace.setVisible(false);
        }
        
        this.initiateConnectionChanges();
    });
}
 
開發者ID:viskell,項目名稱:viskell,代碼行數:25,代碼來源:ConstantBlock.java


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