Files
csa-final-project/testInput.java
2026-05-06 23:44:37 -05:00

50 lines
1.5 KiB
Java

/**
* @(#)testInput.java
*
* @author
* @version 1.00 2017/1/16
*/
import java.util.*;
import javax.swing.*;
public class testInput {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JTextField field1 = new JTextField();
JTextField field2 = new JTextField();
JTextField field3 = new JTextField();
JTextField field4 = new JTextField();
JTextField field5 = new JTextField();
Object[] message = {
"Input name:",
field1, // list prompt followed by a JTextField object reference for each data element
// in
// your object
"Input other data:", field2,
"meaningful prompt:", field3,
"Input value 4:", field4,
"Input value 5:", field5,
};
field1.setText("initialize data such as Henry here");
int option = JOptionPane.showConfirmDialog(
null, message, "Enter all your values", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) { // Read user input data
String value1 = field1.getText();
String value2 = field2.getText();
String value3 = field3.getText();
String value4 = field4.getText();
String value5 = field5.getText();
System.out.println(
value1 + " " + value2 + " " + value3 + " " + value4 + " "
+ value5); // you would construct an object and add or replace it in the arraylist
} else
System.out.println("no data");
}
}