deleted test files
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
|
||||
/**
|
||||
* @(#)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");
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/**
|
||||
* @(#)testJOptionPane.java
|
||||
*
|
||||
* @author Horton
|
||||
* @version 1.00 2012/5/15
|
||||
*/
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class testJOptionPane2 {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// ## creates a loop to display the main menu
|
||||
boolean done = false;
|
||||
|
||||
while (!done) {
|
||||
String menu =
|
||||
"1 - load file"
|
||||
+ "\n"
|
||||
+ "2 - add something "
|
||||
+ "\n"
|
||||
+ "3 - save file "
|
||||
+ "\n"
|
||||
+ "4- quit";
|
||||
String inputValue = JOptionPane.showInputDialog(menu);
|
||||
int n = Integer.parseInt(inputValue);
|
||||
switch (n) {
|
||||
case 1:
|
||||
loadFile(); // Read data from file
|
||||
break;
|
||||
case 2:
|
||||
doSomething();
|
||||
break;
|
||||
case 3:
|
||||
JOptionPane.showMessageDialog(null, "user instructions here ");
|
||||
break;
|
||||
case 4:
|
||||
done = true;
|
||||
break;
|
||||
default:
|
||||
JOptionPane.showMessageDialog(null, "invalid option, please try again ");
|
||||
}
|
||||
}
|
||||
|
||||
// JOptionPane.showMessageDialog(null,"You Chose " + inputValue);
|
||||
|
||||
// *********************************************************************
|
||||
// Custom button text -- returns 0 for the first button
|
||||
Object[] options = {"Yes, please", "No, thanks", "No eggs, no ham!"};
|
||||
int n =
|
||||
JOptionPane.showOptionDialog(
|
||||
null,
|
||||
"Would you like some green eggs to go " + "with that ham?",
|
||||
"A Silly Question",
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[2]);
|
||||
// ## do not include the following line. It is to help determine what the switch should do
|
||||
JOptionPane.showMessageDialog(null, "You Chose " + n);
|
||||
|
||||
// ****************************************************************
|
||||
// pull down menu
|
||||
// --NOTE: this would be a good place to call a method in your list class to get an array of
|
||||
// objects to display such as all the names of the teams or products in your list.
|
||||
|
||||
Object[] possibilities = {"ham", "spam", "yam"};
|
||||
String s =
|
||||
(String)
|
||||
JOptionPane.showInputDialog(
|
||||
null,
|
||||
"Complete the sentence:\n" + "\"Green eggs and...\"",
|
||||
"Customized Dialog",
|
||||
JOptionPane.PLAIN_MESSAGE,
|
||||
null, // icon if you have one
|
||||
possibilities,
|
||||
"ham");
|
||||
}
|
||||
|
||||
public static void doSomething() {
|
||||
// ## this method is just to show displaying
|
||||
// ## a different menu. You would need to
|
||||
// ## add a switch to handle menu options
|
||||
// ## when option 4 is selected,the loop/method will end
|
||||
// ## and processing can return to the menu that called this
|
||||
|
||||
boolean editMore = true;
|
||||
while (editMore) {
|
||||
String menu =
|
||||
"1 - show all data"
|
||||
+ "\n"
|
||||
+ "2 - show only one thing "
|
||||
+ "\n"
|
||||
+ "3 - save file "
|
||||
+ "\n"
|
||||
+ "4 - done editing ";
|
||||
String inputValue = JOptionPane.showInputDialog(menu);
|
||||
// out write a switch to evaluate the options -- following if would be in your switch
|
||||
if (inputValue.equals("4")) editMore = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadFile() {
|
||||
// loop, read data for one record, construct object of that class, add to the appropriate list
|
||||
/**
|
||||
* Scanner saved; try { saved = new Scanner (new File("itemList.dat")); while(saved.hasNext()) {
|
||||
* itemName = saved.nextLine(); itemPrice = saved.nextDouble(); itemQuantity = saved.nextInt();
|
||||
* saved.nextLine(); //cleans out end of line myCart.addItem(new ItemKEY(itemName, itemPrice,
|
||||
* itemQuantity)); } //end of while block to read } // end of try block catch (IOException e) {
|
||||
* System.out.println ("input read failed " + e); }
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user