Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m working on a project, and I have a couple of issues. 1.) I\'m using the Net

ID: 3640719 • Letter: I

Question

I'm working on a project, and I have a couple of issues.

1.) I'm using the Netbeans GUI, and I want a particular text field to accept user input in the form of a valid date. Is there a class that you can attach to the text field to allow a user to choose a date, or some other way to validate that the date entered is, in fact, a valid date?

2.) I want the user to be able to add records to a file, and I want those particular entries to appear under the corresponding sections. Let's say we want to track John's, Jill's, and Bob's purchases. The clerk can add a record, via above-mentioned user input, to a given customer's "file". When the user asks to see all of John's, only John's purchases are brought up. Such as:

John
Number of Purchases: 2

3-11-12 : Hammer
3-14-12 : Vacuum

---EoF

How in the heck do I go about something like that using NetBeans and GUI? Working under the assumption that this program would allow for a lot more customers and purchases.

Explanation / Answer

1.) I'm using the Netbeans GUI, and I want a particular text field to accept user input in the form of a valid date. Is there a class that you can attach to the text field to allow a user to choose a date, or some other way to validate that the date entered is, in fact, a valid date?

Jave doesn't have built-in code for datechooser. You can build your own by simply adding 3 checkboxes (Month-Day-YEAR) with built-in values and that will not enter invalid dates. Another way is to use SimpleDateFormat and Date class in java to check for date Validation. Either one works.

2.) I want the user to be able to add records to a file, and I want those particular entries to appear under the corresponding sections. Let's say we want to track John's, Jill's, and Bob's purchases. The clerk can add a record, via above-mentioned user input, to a given customer's "file". When the user asks to see all of John's, only John's purchases are brought up. Such as:

Easy way to do this is to create one file..called--- purchases.txt and save the file format like below

CUSTOMER NAME<space>PURCHASE DATE<space> ITEM NAME

John 3-11-12 Hammer

John 3-14-12 Vaccum

Robert 4-14-12 Table

Robert 4-15-12 Lamp

.

.

....EOF

Load all customers when you initiate the program and store them in ArrayList and pull the information you need. If you make changes write it back to file and store it. If you have any questions let me know.

John
Number of Purchases: 2

3-11-12 : Hammer
3-14-12 : Vacuum

---EoF