Additional Notes
ItemListener
For the ItemStateChange, if you open your JavaDocs, go to
the java.awt.event package, and then go to the ItemListener interface, you
will see in the method summary section the following:
What this tells me is that if my class implements
ItemListener, then I have to include a method with this signature:
public void itemStateChanged(ItemEvent e) {
}
If I have a Choice named itemNames, then I need to add it
as an ItemListener:
itemNames.addItemListener(this);
Now, when a user selects an Item in the Choice, the
itemStateChanged event is fired.
A Choice has a method called getSelectedIndex(). Use the
index value to pull the related ID from an array.
A lot of knowing Java is knowing how to navigate the
JavaDocs. I use them constantly.
Application Flow
The flow is like this:
- Frontend starts
- Frontend requests connection
- Listener accepts connection
- Listener passes connection to FileReader
- Frontend sends LO to FileReader
- FileReader sends comma-separated list to Frontend
- Frontend parses list and populates Choice
- User selects from Choice
- Front
- Frontend requests connection
- Listener accepts connection
- Listener passes connection to FileReader
- Frontend sends R# to FileReader
- FileReader sends comma-separated list to Frontend
- Frontend parses list and populates TextFields
Your file is line after line in the following format:
ID,Name,Property1,Property2,Property3. You need to manually create
this text file using a text editor.
The comma-separated list for Step 6 is in the format ID,Name,ID,Name........etc.
It needs to read every line in the file and generate this string.
The comma-separated list for Step 14 is on of the lines from the file in the
format ID,Name,Property1,Property2,Property3 where the ID matches the # sent
in Step 13.