Hi,

i am new to java.....

i was wondering if someone can hlep me with the code to substitute the use of showInputdialog.

currently i am using the following code to recieve Strings, but i do not want to use the java dialog boxes. is it possible to do something like c++ has (cin)?

my code is as follows:

blah blah

String price = "";  // initialized the variable price to empty string
        
        ArrayList keypad = new ArrayList(); // create an arraylist and name it
                                                        // keypad
        
        while (true) // continuous loop to stop when arrayList is
                        // empty
        {
            try                     // read data from console
            {
                BufferedReader br =
                    new BufferedReader(new InputStreamReader(System.in), 1);
                System.out.println("Enter price");
                System.out.flush();
                price = br.readLine();
            }
            
            catch (IOException ioe) // if error then catch error
            {
                System.out.println(ioe);
            }

keypad.add(price);  // put data read from console into stack

thx in advance..... or can someone help fix my code so that i can then compare price with a + sign, or = sign or an int.....?

thx
ra2833

Have you tried JOptionPane class

doesn't JOptionPane meant that i will be using a dialog box? if so, this is not what i want, i do not want to use dialog boxes....


what i am looking for is something simple, that will recieve a string from the console or a function call.

for example in C++:

cout << "Please enter a number:" ;
cin >> number;

here, there is no dialog box's, just a simple request and simple recive.

thx

This article has been dead for over six months. Start a new discussion instead.