944,201 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3892
  • Java RSS
Nov 1st, 2004
0

Need Help on showInputDialog

Expand Post »
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
Java Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ra2833 is offline Offline
7 posts
since Nov 2004
Nov 2nd, 2004
0

Re: Need Help on showInputDialog

Have you tried JOptionPane class
Reputation Points: 10
Solved Threads: 0
Newbie Poster
oceanboy is offline Offline
4 posts
since Nov 2004
Nov 2nd, 2004
0

Re: Need Help on showInputDialog

Quote 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ra2833 is offline Offline
7 posts
since Nov 2004
Nov 2nd, 2004
0

Re: Need Help on showInputDialog

moderator please retire this thread?

thx
ra2833
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ra2833 is offline Offline
7 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: help? trying to compare input with symbol.
Next Thread in Java Forum Timeline: help? trying to compare input with symbol.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC