How about a class for simple input?
I have created the SimpleInput class to let you get input from a user via a pop-up dialog box. It uses the swing class javax.swing.JOptionPane. All of these check that the user actually input what was asked for and if not will ask again.
To use it just right click on SimpleInput.java and then click on "Save Target As" and put it in your bookClasses directory. Do the same thing with
SimpleInput.class.
Then in the interactions pane or in a method try:
double number = SimpleInput.getNumber("Please enter a number");
System.out.println(number);
or to get an integer try:
int number = SimpleInput.getIntNumber("Please enter an integer");
System.out.println(number);
or to get a String try:
String answer = SimpleInput.getString("What is your name?");
System.out.println(answer);
or to get an integer between a minimum and maximum value try:
int number = SimpleInput.getIntNumber("Enter a number from 1 to 10",1,10);
System.out.println(number);
Link to this Page
- Questions last edited on 30 January 2006 at 1:29 pm by user-11216ng.dsl.mindspring.com