Need Help on showInputDialog

Reply

Join Date: Nov 2004
Posts: 7
Reputation: ra2833 is an unknown quantity at this point 
Solved Threads: 0
ra2833 ra2833 is offline Offline
Newbie Poster

Need Help on showInputDialog

 
0
  #1
Nov 1st, 2004
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
  1. String price = ""; // initialized the variable price to empty string
  2.  
  3. ArrayList keypad = new ArrayList(); // create an arraylist and name it
  4. // keypad
  5.  
  6. while (true) // continuous loop to stop when arrayList is
  7. // empty
  8. {
  9. try // read data from console
  10. {
  11. BufferedReader br =
  12. new BufferedReader(new InputStreamReader(System.in), 1);
  13. System.out.println("Enter price");
  14. System.out.flush();
  15. price = br.readLine();
  16. }
  17.  
  18. catch (IOException ioe) // if error then catch error
  19. {
  20. System.out.println(ioe);
  21. }
  22.  
  23. 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
Last edited by alc6379; Nov 2nd, 2004 at 4:01 pm. Reason: added [code] tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 4
Reputation: oceanboy is an unknown quantity at this point 
Solved Threads: 0
oceanboy oceanboy is offline Offline
Newbie Poster

Re: Need Help on showInputDialog

 
0
  #2
Nov 2nd, 2004
Have you tried JOptionPane class
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 7
Reputation: ra2833 is an unknown quantity at this point 
Solved Threads: 0
ra2833 ra2833 is offline Offline
Newbie Poster

Re: Need Help on showInputDialog

 
0
  #3
Nov 2nd, 2004
Originally Posted by oceanboy
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 7
Reputation: ra2833 is an unknown quantity at this point 
Solved Threads: 0
ra2833 ra2833 is offline Offline
Newbie Poster

Re: Need Help on showInputDialog

 
0
  #4
Nov 2nd, 2004
moderator please retire this thread?

thx
ra2833
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC