JOptionPane.showInternalOptionDialog Question

I'm using the JOptionPane to show an internal dialog. Is there a way such that I can bind the function keys to the options? For instance, my options are "OK", "Cancel" but I want to bind the F3 key to "OK" and the F12 key to "Cancel".
Thanks

You have to write your own JDialog/JInternalFrame - if you like, you can use JOptionPane's createDialog(...) or createInternalFrame(...) methods. Then attach a keyListener for example.

Similar Messages

  • JOptionPane Closing Question

    I am trying to close a dialog window when a boolean variable in another class changes to false. I use JOptionPane inside of an instance of Dialog. I have tried using hide(), dispose(), and setVisible(false). The problem is that the dialog window does not know to check the variable. Do I need to add some kind of event listener or what? I know this isn't compilable but I think this is a simple question, I must just be overlooking something...
          Object[] options = {"Stop"};         
             JOptionPane optionPane = new JOptionPane("Playing...",          
                  JOptionPane.OK_OPTION,
               JOptionPane.INFORMATION_MESSAGE,
               dialogIcon,     //don't use a custom Icon
               options,  //the titles of buttons
               options[0]); //default button title
             Dialog playingDialog = optionPane.createDialog(frame, "Status");
             playingDialog.setVisible(true);
             //here is what needs to happen when the orhb class sets getPlayState to false
             if(!orhb.getPlayState()){
               System.out.println("done playing, close window");
               setVisible(false);
             }

    Here is the code that provoked my answer, above:Yea, I thought the same thing at first but then I when I re-read it, I realized that the OP was saying this code:
    //here is what needs to happen when the orhb
    class sets getPlayState to false
    if(!orhb.getPlayState()){
    System.out.println("done playing, close window");
    setVisible(false); is not being called and the question was where to put it. (Of course once he determines where to put that code he will have to call it on the appropriate object)

  • JOptionPane input question

    Hi everybody,
    I have JOptionPane input dialog in a program to input file names, and I have a lot of text files to input, over 20. They all come from the same folder, the only difference is their names. Does anyone know, is there a way to have the JOptionPane show the last thing I inputted when it comes up again, so I don't have to type the whole file name again. For example (this isn't exactly code, but I'm formatting it that way so it's clear):
    String fileMined = the result from the JOptionPane input dialog
    fileMined is saved and used to create a button
    If the user wants more input the JOptionPane comes up again
    Show the previous fileMined, but let the user change part of it
    Save the new string as fileMinedJust to make sure I'm clear, it would be something like:
    Type in C:\Text.txt in JOptionPane
    Next time JOptionPane comes up, C:\Text.txt is in the input field, and we can just delete "Text" and replace it with whatever other file name we need
    If anyone can tell me how to do this, I'd be very grateful!
    Thanks,
    Jezzica85
    Message was edited by:
    jezzica85

    Thank you Michael, I didn't know there was something with that few parameters. My code still isn't working to put the previous string in the input box, I have a feeling I'm doing something small and silly. So far, I have:
    Object inputString = new String( "" );
                 fileMined = JOptionPane.showInputDialog( "Input File", ( String )inputString );
                 if( ( fileMined != null ) && ( fileMined != "" ) ) {
                      inputString = fileMined;
                 }So once again, I guess, can you tell what I'm doing wrong?
    Thanks again,
    Jezzica85

  • Simple JOptionPane.showOptionDialog() question

    Could you please help me:
    Here's a piece of code:
    JPasswordField field = new JPasswordField();
    int choice = JOptionPane.showOptionDialog(null, field, "Enter password:", 0,
    JOptionPane.QUESTION_MESSAGE, null,
    new String[] {"ОК", "Cancel"}
    , null);
    How to make an enter-key-press on JPasswordField to be equivalent to pressing OK key?? If it's possible or i should use bigger constructions (like private class PasswordAskClass extends JDialog) ???
    Thanks in advance for your replies.

    The problem is that you don't have a reference to the OK button.
    1) use a JDialog like you suggest.
    2) Create the buttons yourself, and pass them into JOptionPane as arguments.
    Then you'll be able to add a KeyMap to your JPasswordField that when ENTER is pressed, it sends an action event to your OK button.

  • JOptionPane and Applet problem

    Hi folks,
    I have an applet, I want to display a pop up dialog whenever the user
    does something. SO i used JOptionPane:
    int userIn=JOptionPane.showInternalConfirmDialog(this,"Do you wish to generate xml for each ics/ids files pair in this data set?", "information",JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
    //repaint();
    The dialog just doesn't show up, I tried repaint(), tried JApplet, nothing works, what am I missing? I'm pretty sure the above code gets called.
    thanks

    A. Are you sure this code is executing?
    B. Are you sure you aren't getting an error, possibly something like
    java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
    at javax.swing.JOptionPane.createInternalFrame(JOptionPane.java:1161)
    at javax.swing.JOptionPane.showInternalOptionDialog(JOptionPane.java:1025)
    at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:967)
    at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:931)

  • Increment  variable in a txt file

    Hello hello [[]] =)
    Just wondering if is it possible to change on string to another , inside a txt file. The problem is:
    Someone ask a question , choose the number of answers, write those answers and send it to a comboBox ( the answers) .
    The person who's gonna answer that question pick an answer from the ComboBox, and the program saves it in a txt file the number of times that that answer was picked. like an inquiry.
    And at the end , it gives the % of each answer, that was picked.
         private class handler implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   String option = combo.getSelectedItem().toString();   // get the selected item from the combobox (answer)
                   int index = combo.getSelectedIndex();     //position of that answer from the comboBox          
                   int count_answer =0;
                   for (int i=0; i!= array.length; i++) // array -> an array of Strings that has all the answers inside it
                        if(option.equals(array)) ++count_answer; // option is the answer picked by the user.
                        try{
                             r = new BufferedReader(new FileReader(option));
                             frame.setVisible(false);
                             rewrite(index, option, count_answer);     
                        }catch(IOException ex){
                             try {
                                  w = new PrintWriter(new FileWriter(option));
                                  w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ count_answer +" time(s)");
                                  frame.setVisible(false);
                                  w.close();
                             } catch (IOException e1) {
                                  e1.printStackTrace();}
         public void rewrite(int index, String option, int count) throws IOException{
         int increment ;
              w = new PrintWriter(new FileWriter(option));
              count = count + increment++;
              w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ count +" time(s)");
              w.close();
    I don't know how to change that variabel "count " inside a txt, so what im doing is increment the variable count++ and rewrite the string again inside that file.
    The problem is that, the variabel "count" counts until two , and that's all, if u run the program again (third time) , it should shows " 3 times ...4 times and so on.."
    but it doesn't.
    thanks

    total code to run :
    package ClienteMsn;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.Label;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    public class Poll {
         private String pergunta;
         private int num_respostas;
         private String[] respostas_possiveis;
         String [] array;
         String [] nomeFiles;
         private JTextArea area = new JTextArea(2,3);
         private JPanel painel_respostas = new JPanel(new FlowLayout(FlowLayout.LEFT));
         private JPanel painel =new JPanel(new BorderLayout());
         private JButton submit = new JButton("Confirm");
         private JPanel painel_botao = new JPanel(new FlowLayout(FlowLayout.CENTER));
         private JFrame frame = new JFrame("Questionario");
         private SentinelaParaAc??es sentinela = new SentinelaParaAc??es();
         private JComboBox combo;
         PrintWriter w;
         BufferedReader r;
         public Poll(final String pergunta, final int num_respostas, final String[] respostas_possiveis) {
              this.respostas_possiveis = respostas_possiveis;
              this.pergunta = pergunta;
              this.num_respostas = num_respostas;
              array = respostas_possiveis;
              combo = new JComboBox(respostas_possiveis);
              nomeFiles = new String[num_respostas];
              Container contentor = frame.getContentPane();
              contentor.setLayout(new BorderLayout(0, 20));
              area.setBackground(Color.WHITE);
              Label label = new Label("Resposta:     ");
              label.setFont(new Font("", Font.BOLD, 12));
              painel_botao.add(submit);
              area.setFont(new Font("", Font.BOLD, 13));
              area.append(pergunta);
              painel.add(label, BorderLayout.WEST);
              painel.add(combo, BorderLayout.CENTER);
              painel_respostas.add(painel);
              contentor.add(painel_respostas, BorderLayout.CENTER);
              contentor.add(area, BorderLayout.NORTH);
              contentor.add(painel_botao, BorderLayout.SOUTH);
              submit.addActionListener(sentinela);
         public int getNum_respostas() {
              return num_respostas;
         public String getPergunta() {
              return pergunta;
         public String[] getRespostas_possiveis() {
              return respostas_possiveis;
         public void executa() {
              frame.setLocation(300,300);
              frame.setSize(550, 190);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private class SentinelaParaAc??es implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   String option = combo.getSelectedItem().toString();
                   int index = combo.getSelectedIndex();               
                   int cont_answer =0;
                   for (int i=0; i!= array.length; i++)
                        if(option.equals(array)) ++cont_answer;
                        try{
                             r = new BufferedReader(new FileReader(option));
                             frame.setVisible(false);
                             rewrite(index, option, cont_answer);     
                        }catch(IOException ex){
                             try {
                                  w = new PrintWriter(new FileWriter(option));
                                  w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ cont_answer +" time(s)");
                                  frame.setVisible(false);
                                  w.close();
                             } catch (IOException e1) {
                                  e1.printStackTrace();}
         public void rewrite(int index, String option, int count) throws IOException{
              w = new PrintWriter(new FileWriter(option));
              int increment = 0 ;
              count = count + (++increment);
              w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ count +" time(s)");
              w.close();
         public static void main(String[] xxx){
              String [] recolhe = null;
              String pergunta = JOptionPane.showInputDialog("Question: ");
              String r = JOptionPane.showInputDialog("Number of answers: ");
              int numrespostas = Integer.parseInt(r);
              recolhe = new String[numrespostas];
              int i = 0;
              while(i != numrespostas){
                   String respostas = JOptionPane.showInputDialog("Answer ("+(i+1)+") :");
                   recolhe[i] = respostas;
                   i++;
              new Poll(pergunta, numrespostas, recolhe).executa();
    Message was edited by:
    Java__Estudante

  • Modal JInternalFrame

    Is it possible to create a JInternalFrame which behaves like a modal dialog for anothre JInternalFrame?

    There is numerous methods available in JOptionPane viz..
    1)JOptionPane.showInternalMessageDialog();
    2)JOptionPane.showInternalConfirmDialog()
    3)JOptionPane.showInternalOptionDialog()
    etc ...etc
    Just have a glance on Java Doc ->Swing->JOptionPane
    :)

  • Display an icon(question,warning,etc.) inside JDialog(like in JOptionPane)

    Hello,
    because JOptionPane can't use a JPasswordField as the input component, I created a JDialog prompting the user for a password. Now I can't figure out how to show that nice look-and-feel style icon inside the dialog (the question mark that is shown when you use messageType=QUESTION_MESSAGE in JOptionPane). Shortly, this is what I have and this is what I want to get... I tried this:
    dlg.getRootPane().setWindowDecorationStyle(JRootPane.QUESTION_DIALOG)But it does nothing. Could you help me, please?
    Thank you
    Ondra

    Still it doesn't answer my question: how to display the LAF icon inside a JDialog.Huh?import javax.swing.*;
    public class OptionPanePassword {
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new OptionPanePassword().makeUI();
       public void makeUI() {
          JLabel label =new JLabel("Enter Password: ");
          JPasswordField field = new JPasswordField(15);
          JPanel panel = new JPanel();
          BoxLayout layout = new BoxLayout(panel, BoxLayout.X_AXIS);
          panel.setLayout(layout);
          panel.add(label);
          panel.add(field);
          JOptionPane.showConfirmDialog(null, panel, "",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    }db

  • Swing beginner JOptionPane question

    Hi
    my question is:
    When I construct an input dialog like this:
    JOptionPane.showInputDialog(null, "enter something here");
    by default the buttons available are OK and Cancel. How do I capture the Cancel button being clicked to make the system exit?
    I know I can call System.exit(0) but how do I do that when clicking Cancel?
    Thanks for any help

    JOptionPane.showInputDialog(null, "enter something here") returns a string, if the user clicks cancel then it returns null. so you can do something like this...
    String str = JOptionPane.showInputDialog(null, "enter something here");
    if(str != null){/*do 'ok' stuff*/;}
    else{/*do cancel stuff*/;}hope that helps

  • Quick JOptionPane question

    my code is
    Str = JOptionPane.showInputDialog(null, "Question",
                   "Title");
    how do i edit what the cancel button does? i looked on tutorial page and couldnt find it
    i just want it to System.exit(0)
    right now it crashes my program
    Edited by: hiby220 on Nov 8, 2008 2:12 PM

    i realized i should of put it in the code format, and was in middle of editing my post to do so, but you posted something before i had chance to finish. cant edit after someone posts
    double input;
    str = JOptionPane.showInputDialog(null, "Question");
    //make sure user entered a valid input
    try {input = Double.parseDouble(str);
    } catch (NumberFormatException e) { //on this line
    JOptionPane.showMessageDialog(null, "That is not a valid input! System exiting");
    System.exit(0);
    }better? and you telling me that simplifying it messes things up makes no sense...
    now when i run it and press cancel i get a java.lang.NullPointerException the specified line
    but since you insist on having my real code here it is package one;
    import java.io.*;
    import java.util.Scanner;
    import javax.swing.JOptionPane;
    import java.text.DecimalFormat;
    public class ATM2 {
           !! Ronnie Girardot !!
         static double totalCost, amount, cost, commission, Rate, USDtoCanD, USDtoMexPeso, USDtoEuro;
         static String currencyStr, Transaction, BankName;
         static boolean quit = false;
         static DecimalFormat formatter = new DecimalFormat("$#0.00");
         public static void main(String[] args) throws IOException {
              readDailyFile();
              welcome();
              while(!quit){
                   getCurrency();
                   Transaction = getTransaction();
                   if (Transaction == "Buys")
                        buyTransaction();
                   else if (Transaction == "Sells")
                        sellTransaction();
              showResults();
              writeLog();
         public static void readDailyFile() throws IOException {
              //get daily exchange rates via dailyRates.txt
              File file = new File("dailyRates.txt");
              //make sure dailyRate.txt exists
              if (!file.exists())
                   System.out.println("The file dailyRates.txt is not found.");
                   System.exit(0);
              Scanner input = new Scanner(file);
              //take all needed information out of dailyRates.txt
              BankName = input.nextLine();
              USDtoCanD = input.nextDouble();
              USDtoMexPeso = input.nextDouble();
              USDtoEuro = input.nextDouble();
         public static void welcome(){
         JOptionPane.showMessageDialog(null, "Hello and welcome to " + BankName + ",\n the best bank in the world!",
                   BankName,
                  JOptionPane.WARNING_MESSAGE);
         public static void getCurrency(){
              //show dialog asking what they wish to convert their USD to
              Object[] options = {"Canadian Dollar", "Mexican Peso", "Euro", "Cancel"};
            int n = JOptionPane.showOptionDialog(null,
            "Here you select which currency you are intrested in.\n" +
            "The next page then asks if you wish to buy or sell.\n" +
            "(The currect USD is worth " + formatter.format(USDtoCanD) + " Canadian, " + formatter.format(USDtoMexPeso) + " Pesos, " + formatter.format(USDtoEuro) + " Euros)",
            BankName + ", the best bank in the world.",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null, options, options[2]);
            switch(n){
            case 0:
                 currencyStr = "Canadian Dollars";
                 break;
            case 1:
                 currencyStr = "Pesos";
                 break;
            case 2:
                 currencyStr = "Euros";
                 break;
            case 3:
                 System.exit(0);
         public static String getTransaction(){
              String Action = "";
              //see if user wants to buy or sell
              Object[] options = {"Buy", "Sell", "Cancel"};
            int n = JOptionPane.showOptionDialog(null,
            "Do you wish to buy or sell " + currencyStr,
            BankName + ", the best bank in the world.",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null, options, options[2]);
            switch(n){
            case 0:
                 Action = "Buys";
                 break;
            case 1:
                 Action = "Sells";
                 break;
            case 2:
                 System.exit(0);     
              return Action;
         public static void buyTransaction(){
              String amountStr;
              //get amount user wishes to buy
              amountStr = JOptionPane.showInputDialog(null, "How many " + currencyStr +" do you wish to buy?");
              //make sure user entered a valid input
              try {amount = Double.parseDouble(amountStr);
                   } catch (NumberFormatException e) {
                         JOptionPane.showMessageDialog(null, "That is not a valid input! System exiting");
                         System.exit(0);
              //find out which rate to use
                   if (currencyStr == "Canadian Dollars")
                   Rate = USDtoCanD;
              else if (currencyStr == "Pesos")
                   Rate = USDtoMexPeso;
              else if (currencyStr == "Euros")
                   Rate = USDtoEuro;
              //find USD cost
              cost = amount / Rate;
              //find commission cost on USD amount
              commission = cost * .015;
              totalCost = cost + commission;
    public static void sellTransaction(){
         String amountStr;
         //get amount user wishes to sell
         amountStr = JOptionPane.showInputDialog(null, "How many " + currencyStr +" do you wish to sell?");
         //make sure user entered a valid input
         try {amount = Double.parseDouble(amountStr);
              } catch (NumberFormatException e) {
                    JOptionPane.showMessageDialog(null, "That is not a valid input! System exiting");
                    System.exit(0);
         //find out which rate to use
              if (currencyStr == "Canadian Dollars")
              Rate = USDtoCanD;
         else if (currencyStr == "Pesos")
              Rate = USDtoMexPeso;
         else if (currencyStr == "Euros")
              Rate = USDtoEuro;
         //find USD cost
         cost = amount / Rate;
         //find commission cost on USD amount
         commission = cost * .015;
         totalCost = cost + commission;
         public static void showResults(){
              String str = "";
              if (Transaction == "Buys")
                   str = "US Dollar cost  = ";
              else if (Transaction == "Sells")
                   str = "US Dollar gain  = ";
              JOptionPane.showMessageDialog(null, Transaction + " " + formatter.format(amount) + " " + currencyStr + "\n"
                        + str + formatter.format(cost) + "\n" +
                          "Commission     = " + formatter.format(commission) + "\n" +
                          "Total cost          = " + formatter.format(totalCost));
              //see if user wants to make another transaction
              Object[] options = {"Yes", "No", "Cancel"};
            int n = JOptionPane.showOptionDialog(null,
            "Do you want to make another transaction?",
            BankName + ", the best bank in the world.",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null, options, options[2]);
            if (n == 1) System.exit(0);
            else if (n == 2) System.exit(0);
         public static void writeLog(){
    } i couldnt just cut out any of my real code because its a little complex. note i know its not finished yet, so dont complain about infinite loops or the blank writeLog() method

  • Joptionpane Question dialog

    Hi All,
    Iam using JOptionPane.showConfirmDialog() for a question dialog .Here Iam getting the dialog window but my requirement is I need to get a dialog window in which the close option (X) should be disabled.
    Eg: JOptionPane.showConfirmDialog(this, " Desea ver su contenido","Question",JOptionPane.YES_NO_OPTION,JOptionPane.NO_OPTION)
    Regards,
    Ps

    From API documentation. Try to configure the JDialog used :
    To create and use an JOptionPane directly, the standard pattern is roughly as follows:
         JOptionPane pane = new JOptionPane(arguments);
         pane.set.Xxxx(...); // Configure
         JDialog dialog = pane.createDialog(parentComponent, title);
         dialog.show();
         Object selectedValue = pane.getValue();
         if(selectedValue == null)
           return CLOSED_OPTION;
         //If there is not an array of option buttons:
         if(options == null) {
           if(selectedValue instanceof Integer)
              return ((Integer)selectedValue).intValue();
           return CLOSED_OPTION;
         //If there is an array of option buttons:
         for(int counter = 0, maxCounter = options.length;
            counter < maxCounter; counter++) {
            if(options[counter].equals(selectedValue))
            return counter;
         return CLOSED_OPTION;

  • A question about JOptionPane.showOptionDialog()?

    one problem confused me.
    import javax.swing.*;
    class Test
    public Test()
         int n;
         String title;
         Object[] message = new Object[3];
         Object[] obj = new Object[2];
         message[0] = "Name ";
         message[1] = "Age";
         title = "Information";
         obj[0] = "OK";
         obj[1] = "Cancel";
         n = JOptionPane.showOptionDialog(null,
         message,
         title,
    JOptionPane.OK_CANCEL_OPTION,
              JOptionPane.INFORMATION_MESSAGE,
                        null,
                        obj,
                        obj[0]);               
         public static void main(String[] args)
              new Test();
    i run the java compiler in command line.
    c:\proj1>javac Test.java
    c:\proj1>java Test
    Having done the program, i found that command line didnot return to "c:\proj1>"
    only after "Ctrl-c" can that return back to the "c:\proj1". i didnot meet this problem when i run other java projects.
    what's the problem?
    thanks!

    Implement a call to System.exit(0) at the point you want the programm to close.
    (Depending on the return code of your option dialog)

  • QUESTION ABOUT JOPTIONPANES

    Does anybody knows how can I change the font of the String text messagedialog in a JOptionPane, I kNow how to control de icon but not the font of this text, I would apreciate any help , thankyou very much

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class OptionPaneDemo extends JFrame {
         JFrame jf;
         OptionPaneDemo(){
              jf = new JFrame();
              jf.setVisible(true);
              jf.validate();
              jf.setBounds(100,100,200,200);
              //jf.pack();
              jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container cp = jf.getContentPane();
              JOptionPane jop = new JOptionPane();
              jop.showMessageDialog(jf,"<HTML><FONT SIZE=\"32\">This is Swing</FONT></HTML>");
         public static void main (String args[]){
              OptionPaneDemo opd = new OptionPaneDemo();
    }

  • JOptionPane Question...Help!

    Is there a way to create a JOptionPane and not have any buttons at the bottom to select from? Please help!

    Theoretically, you could create a class which extends JOptionPane and then override the createDialog method, so as to "remove" the buttons from the Panel. But practically, I would not advise you on it because
    1. The code will look messy
    2. It would be much more practical to create a JDialog and use it.
    hope this helps....
    if you have any particular requirements, where JOptionPane cannot substituted by JDialog, do let me know.

  • JOptionPane question

    Hi
    How can I change the text that appears on buttons using the
    Object JOptionPane.showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue)
    method?
    Thans for help
    Best regards
    Piotrek

    Hey
    I don't think I understand. I don't create a JTextField because I don't have to, it's already there on the JOptionPane, so I don't know its name (if it has any) and I can't get its value with getText() method.
    In your code it looks like you take a String value from a JTextField that is probably placed somewhere in a JFrame and you have two button, after pressing 1st you remember the text in a variable storeText, and after pressing 2nd you clear the JTextField.
    Let's say I have a label on my JFrame
    Jlabel jl=new Jlabel("");I open a JOptionPane with a JTextField in it, enter some String value, press OK and set the label to the String
    String findme=(String)JOptionPane.showInputDialog(this,"Searching...","Find",JOptionPane.PLAIN_MESSAGE,null,null,null);
    if(findme!=null)
      jl.setText(findme);
    else
      jl.setText("You have cancelled");I know I can change the initial value of buttons in showOptionDialog(...) but how to do this with showInputDialog(...)?
    I tried to use code like below:
          Object[] pol={"Find","Leave it"};
          JOptionPane jop=new JOptionPane();
          jop.setOptions(pol);
          jop.setOptionType(JOptionPane.YES_NO_OPTION);
          String findme=(String)jop.showInputDialog(this,"Searching...","Find",JOptionPane.PLAIN_MESSAGE,null,null,"Enter value");but it doesn't work as I'd like it to.
    Best regards
    Piotrek

Maybe you are looking for

  • Javascript and html menu to be used with ADF/JSF using JDeveloper

    I have a menu for a webpage that was originally built using html and javascript. I need to convert it to be used with JSF and ADF. In the html, the menu items used an unordered list inside of a div tag. It looks something like this: <!--<div id="shad

  • Photos, viruses, what in the world???

    Please help if you can... I updated my husband's nano today, 1st time on this computer since he returned from overseas... his ipod now has over 400 pictures on it, however, my computer currently has only about 30. Our computer has been having issues

  • Weird workaround for syncing from Aperture

    I sometimes regret moving from iPhoto to Aperture. It ought to be an improvement, but there are problems with iPhone syncing. Lots of posts here about that. I have my iPhone 4 set to sync all photos from Aperture. I noticed some individual photos wer

  • How do I get Menu to show at top of organizer?

    All I have is very tiny double arrow that's very hard to see.  Holding cursor on the arrows brings up "file" "edit" etc vertically ( so it can be used), but otherwise it's just dark. Tried right clicking on arrows; nothing happened.  Right clicked to

  • PDF Changing JPEG size

    Is there a way to stop my jpegs from changing size? I have them at 8.5 by 11 (300 dpi) before converting and now they are 35.42" by 45.83 (100 dpi) and these are not the proper size to send to commercial printer? Is there a way to keep this from happ