View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

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 and then click on "Save Target As" and put it in your bookClasses directory. Do the same thing with

Then in the interactions pane or in a method try:

double number = SimpleInput.getNumber("Please enter a number");

Uploaded Image: getNumber.jpg

or to get an integer try:

int number = SimpleInput.getIntNumber("Please enter an integer");

Uploaded Image: getInt.jpg

or to get a String try:

String answer = SimpleInput.getString("What is your name?");

Uploaded Image: getString.jpg

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);

Uploaded Image: getIntInRange.jpg

Link to this Page