当前位置: 首页>>代码示例>>Java>>正文


Java JOptionPane.showInputDialog方法代码示例

本文整理汇总了Java中javax.swing.JOptionPane.showInputDialog方法的典型用法代码示例。如果您正苦于以下问题:Java JOptionPane.showInputDialog方法的具体用法?Java JOptionPane.showInputDialog怎么用?Java JOptionPane.showInputDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JOptionPane的用法示例。


在下文中一共展示了JOptionPane.showInputDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: takeScreenCap

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public void takeScreenCap(ActionEvent e){
  	String inputValue = JOptionPane.showInputDialog("Choose a name for your screen capture.");
  	
  	SwingUtilities.getWindowAncestor(this).setVisible(false);
int option = JOptionPane.showConfirmDialog(null,
		"Click yes to capture screen, no to cancel.", "Take Capture", JOptionPane.YES_NO_OPTION);
if(option ==0)
{
	try{
  			Thread.sleep(1000);
  			
  		} catch(InterruptedException ex){
  			Thread.currentThread().interrupt();
  		}
	String toLink = Capture.doCapture(inputValue);
	SwingUtilities.getWindowAncestor(this).setVisible(true);
	
	
	toLink = "file:" + toLink;
	imageCaptureStart(toLink);
}
SwingUtilities.getWindowAncestor(this).setVisible(true);
  }
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:24,代码来源:HTMLEditor.java

示例2: promptForDragCount

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public void promptForDragCount() {
  while (true) {
    final String s = JOptionPane.showInputDialog(
      Resources.getString("Deck.enter_the_number")); //$NON-NLS-1$
    if (s != null) {
      try {
        dragCount = Integer.parseInt(s);
        dragCount = Math.min(dragCount, getPieceCount());
        if (dragCount >= 0) break;
      }
      catch (NumberFormatException ex) {
        // Ignore if user doesn't enter a number
      }
    }
    else {
      break;
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:20,代码来源:Deck.java

示例3: main

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public static void main(String[] args) {
	 Conjugaison InputConjugaison = new Conjugaison();
	    String result = JOptionPane.showInputDialog(null, "Veuillez entrer un verbe à l'infinitif se terminant par «er» :");
	    boolean resultat = InputConjugaison.estVerbeER(result);
	    if (resultat == true) {
	    		JOptionPane.showMessageDialog(null, InputConjugaison.afficheTable());
	    }
	    else {
	    		JOptionPane.showMessageDialog(null,"Vous n'avez pas fourni un verbe se terminant par «er».");
	    }

}
 
开发者ID:mguaylambert,项目名称:JavaClass,代码行数:13,代码来源:Interface.java

示例4: main

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public static void main(String[] args)
{
   // prompt user to enter name
   String name = JOptionPane.showInputDialog("What is your name?");
   
   // create the message
   String message =                                              
      String.format("Welcome, %s, to Java Programming!", name);

   // display the message to welcome the user by name 
   JOptionPane.showMessageDialog(null, message);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:13,代码来源:NameDialog.java

示例5: addChildBranch

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public void addChildBranch() {
    int row = table.getSelectedRow();
    if (row < 0)
        return;
    Node node = (Node) table.getPathForRow(row).getLastPathComponent();
    String message = GlobalResourcesManager
            .getString("BranchCreationWarning");
    if (node.branch.getChildren().size() > 0)
        message = GlobalResourcesManager
                .getString("BranchNodeCreationWarniong");
    if (JOptionPane.showConfirmDialog(framework.getMainFrame(), message,
            UIManager.getString("OptionPane.titleText"),
            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION)
        return;
    String s = JOptionPane.showInputDialog(framework.getMainFrame(),
            GlobalResourcesManager.getString("BranchCreationReason"),
            GlobalResourcesManager.getString("BranchCreationReason"),
            JOptionPane.QUESTION_MESSAGE);
    if (s == null)
        return;
    int type = node.branch.getType() - 1;
    if (node.branch.getChildren().size() > 0) {
        type = getMaxType(type, (Node) branchModel.getRoot());
    }
    engine.createBranch(node.branch.getBranchId(), s, type + 1, "core");
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:27,代码来源:BranchView.java

示例6: execute

import javax.swing.JOptionPane; //导入方法依赖的package包/类
@Override
public void execute() {
    String input = JOptionPane.showInputDialog("Input Grammar URL:");
    if (input != null) {
        try {
            URL url = new URL(input);
            final SystemStore store = SystemStore.newStore(url);
            //                String startGraphName = url.getQuery();
            getActions().getLoadGrammarAction().load(store);
        } catch (MalformedURLException e) {
            showErrorDialog(e,
                String.format("Invalid URL '%s'", e.getMessage()));
        } catch (IOException exc) {
            showErrorDialog(exc, exc.getMessage());
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:18,代码来源:LoadGrammarFromURLAction.java

示例7: actionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
    String name = (String) JOptionPane.showInputDialog(AddressBookPanel.this,
            "Please enter the name of the contact:",
            "Add new contact step 1",
            JOptionPane.PLAIN_MESSAGE,
            null,
            null,
            "");
    if (name == null || "".equals(name))
        return; // cancelled

    // TODO: check for dupes
    names.add(name);

    String address = (String) JOptionPane.showInputDialog(AddressBookPanel.this,
            "Pleae enter the t-address or z-address of "+name,
            "Add new contact step 2",
            JOptionPane.PLAIN_MESSAGE,
            null,
            null,
            "");
    if (address == null || "".equals(address))
        return; // cancelled
    entries.add(new AddressBookEntry(name,address));

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            table.invalidate();
            table.revalidate();
            table.repaint();

            saveEntriesToDisk();
        }
    });
}
 
开发者ID:ca333,项目名称:komodoGUI,代码行数:36,代码来源:AddressBookPanel.java

示例8: edit

import javax.swing.JOptionPane; //导入方法依赖的package包/类
/**
 * Opens a dialog window and asks the user for the name of this axis.
 * 
 * @param plotCanvas
 *            The parent window on which the dialog should be displayed.
 */
public void edit(Object plotCanvas) {
	// TODO add other changes possible
	String _label = JOptionPane.showInputDialog((PlotCanvas) plotCanvas,
			"Choose axis label", label);
	if (_label != null) {
		setLegend(_label);
	}
}
 
开发者ID:Cvarier,项目名称:2D-Elliptic-Mesh-Generator,代码行数:15,代码来源:Axis.java

示例9: actionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e){
	String inputValue = JOptionPane.showInputDialog("Choose a name for your screen capture.");
	
	AppFrame.this.setVisible(false);
	int option = JOptionPane.showConfirmDialog(null,
			"Click yes to capture screen, no to cancel.", "Take Capture", JOptionPane.YES_NO_OPTION);
	
	if(option ==0)
	{
		try{
   			Thread.sleep(1000);
   			
   		} catch(InterruptedException ex){
   			Thread.currentThread().interrupt();
   		}
		String toLink = Capture.doCapture(inputValue);
		AppFrame.this.setVisible(true);
		workPanel.selectPanel("NOTES");
		setEnabledEditorMenus(true);
		workPanel.dailyItemsPanel.editorPanel.newNoteCap();
		toLink = "file:" + toLink;
		editor.imageCaptureStart(toLink);
	}
	else
	{
		AppFrame.this.setVisible(true);
	}
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:29,代码来源:AppFrame.java

示例10: main

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public static void main(String[] args) {
    String p1, p2;
    String fruits[] = {"Maçã", "Banana", "Pêra", "Côco", "Maracujá", "Manga", "Melancia",
    "Melão", "Cereja", "Uva", "Caju", "Laranja", "Pêssego", "Jaca", "Romã", "Mexerica",
    "Tangerina", "Limão", "Abacate"};
    
    p1 = JOptionPane.showInputDialog(null, "1ª Palavra: ", "Palavra", JOptionPane.PLAIN_MESSAGE);
    p2 = JOptionPane.showInputDialog(null, "2ª Palavra: ", "Palavra", JOptionPane.PLAIN_MESSAGE);

    if (p1.compareToIgnoreCase(p2) > 0) {
        String tmp = p1;
        p1 = p2;
        p2 = tmp;
    }
    JOptionPane.showMessageDialog(null, String.format("1º Nome: %s\n2º Nome: %s", p1, p2),
            "Nomes", JOptionPane.PLAIN_MESSAGE);
    
    JOptionPane.showMessageDialog(null, "Primeira letra de " + p1 + " é " + primeiraLetra(p1),
            "Primeira Letra", JOptionPane.PLAIN_MESSAGE);
    JOptionPane.showMessageDialog(null, "Primeira letra de " + p2 + " é " + primeiraLetra(p2),
            "Primeira Letra", JOptionPane.PLAIN_MESSAGE);
    JOptionPane.showMessageDialog(null, "Quantidade de letras de " + p1 + " é " + quantasLetras(p1),
            "Quantas Letras", JOptionPane.PLAIN_MESSAGE);
    JOptionPane.showMessageDialog(null, "Quantidade de letras de " + p2 + " é " + quantasLetras(p2),
            "Quantas Letras", JOptionPane.PLAIN_MESSAGE);
    JOptionPane.showMessageDialog(null, "Última letra de " + p1 + " é " + ultimaLetra(p1),
            "Última Letra", JOptionPane.PLAIN_MESSAGE);
    JOptionPane.showMessageDialog(null, "Última letra de " + p2 + " é " + ultimaLetra(p2),
            "Última Letra", JOptionPane.PLAIN_MESSAGE);
    
    fruits = bubbleSort(fruits);
    
    for (String fruit : fruits)
        System.out.println(fruit);
}
 
开发者ID:Cledersonbc,项目名称:estrutura-de-dados,代码行数:36,代码来源:Ex1.java

示例11: settingsButtonEvent

import javax.swing.JOptionPane; //导入方法依赖的package包/类
private void settingsButtonEvent() {
	String sleepTimeStr = (String)JOptionPane.showInputDialog(networkPanel, "Enter time between updates in milliseconds", "Time between updates", JOptionPane.QUESTION_MESSAGE, null, null, sleepTime);
	if(sleepTimeStr != null) {
		try {
			sleepTime = Long.parseLong(sleepTimeStr);
		} catch (NumberFormatException ex) {
			JOptionPane.showMessageDialog(networkPanel, "The value that you enter is not an integer", "Incorrect input", JOptionPane.WARNING_MESSAGE, null);
		}
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:11,代码来源:DBToolbar.java

示例12: main

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public static void main(String[] args) {
	
	/*
	 * Aqui será mostrado um pouco da utilização dos wrappers 
	 * Perceba que com eles consigo realizar conversões facilmente
	 */
	
	String resposta1 = JOptionPane.showInputDialog("Qual é sua nota 1 ?");
	String resposta2 = JOptionPane.showInputDialog("Qual é sua nota 2 ?");
	
	double nota1 = Double.parseDouble(resposta1);
	double nota2 = Double.parseDouble(resposta2);
	
	System.out.printf("Sua nota é %.2f", (nota1 + nota2) / 2);
}
 
开发者ID:Gigers,项目名称:Examples,代码行数:16,代码来源:ConversaoStringNumero.java

示例13: addCategory

import javax.swing.JOptionPane; //导入方法依赖的package包/类
private static void addCategory(Component frame, String path, File folder_categories) {
    String input = JOptionPane.showInputDialog(frame, StaticStandard.getLang().getLang("new_category_name", "New category name") + ":", path);
    if (input != null && !input.isEmpty()) {
        input = input.replaceAll(File.separator + File.separator, ".");
        File folder = getFolderFromCategory(input, folder_categories);
        StaticStandard.log("Added category: \"" + input + "\"");
        folder.mkdirs();
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:10,代码来源:JTreeUtils.java

示例14: Replace

import javax.swing.JOptionPane; //导入方法依赖的package包/类
public static void Replace(){
    int sel = jTabbedPane1.getSelectedIndex();
    JTextArea textPane = (JTextArea) ((JScrollPane) ((JDesktopPane)jTabbedPane1.getComponentAt(sel)).getComponent(0)).getViewport().getComponent(0);
    try
{
	String replace = JOptionPane.showInputDialog(null, "Replace");
	textPane.replaceSelection(replace);
}catch(NumberFormatException nfe){}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:10,代码来源:BasicEvents.java

示例15: actionPerformed

import javax.swing.JOptionPane; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
	if (EDIT.equals(e.getActionCommand())){
           newInput = JOptionPane.showInputDialog("Edit", oldValue);
           if (newInput == null){
               newInput = oldValue;
           }
           fireEditingStopped();
       }
}
 
开发者ID:anousv,项目名称:OrthancAnonymization,代码行数:11,代码来源:DialogCellEditor.java


注:本文中的javax.swing.JOptionPane.showInputDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。