/*This is a program written in Java 2/Swing for people who brew beer--either at home or in
the industry.  Generally, they will take a reading once a day of the density of the beer--read in
either specific gravity (the equipment available will measure from 1 - 1.090) or degrees Plato
(3.0 - 21.55) depending on the equipment they happen to own.  Then, they need to be able to
convert that value from one unit to the other, keep track of the
values over a course of approximately two weeks, and plot a graph of density vs time.  As
the curve levels out, they know that the beer is "done".

So, this program will take values along with the corresponding dates/times, convert those
values from one unit to the other, display the data, save and load files as the brewer adds
data day by day for two weeks (or more), allows editing of the individual lines when an error is noticed,
and displays a graph of density(specific gravity) vs time.

Since this is a "portfolio" program, I've put in a lot of labels, and even sometimes said
why I did something a certain way.  Be forgiving--this is my first program, and my first
experience with code since I took an "Intro to Basic" course when I was 12.  (And I'm *not*
telling you how old I am now!)*/

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

import java.io.*;


public class SpecificGravityProgram extends JFrame {

    EnterDay  myday;                            //these four classes represent the four sections of the window
    ListDay   mylist;
    EditDay   myedit;
    ShowGraph myshow;
    Vector    entermonthvec  = new Vector();    //as the user enters data, it needs to be saved
    Vector    enterdayvec    = new Vector();    //can't use arrays, since the size will be changing day by day
    Vector    enteryearvec   = new Vector();    //use separate Vectors for each piece of data because it will
    Vector    entertimevec   = new Vector();    //be manipulated separately later
    Vector    enterplatovec  = new Vector();
    Vector    enterspgrvec   = new Vector();
    Vector    spgrboxvec     = new Vector();
    Vector    figurehoursvec = new Vector();
    Vector    graphyvec      = new Vector();
    Vector    graphxvec      = new Vector();
    double    graphy;                           //x and y coordinates for the graph
    double    graphx;
    int       graphindex;
    double    plato;                            //the actual density reading, in either SpGr or Plato
    double    spgr;
    int       editint;
    int[]     editintarr = new int[1];  //when the user chooses to edit a specific line, this array keeps track of which line
                                        //and resets afterward to the next empty space in the Vector    
    int figurehours;                            //to figure the amount of time between entries, in order to set
    int figuremonths;                           //up the x coordinates on the graph
    int figureyears;

// constructor method for GridBagConstraints for main panel (pane)
    void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw,
                          int gh, int wx, int wy) {

        gbc.gridx      = gx;
        gbc.gridy      = gy;
        gbc.gridwidth  = gw;
        gbc.gridheight = gh;
        gbc.weightx    = wx;
        gbc.weighty    = wy;
    }

    public SpecificGravityProgram() {

        super("Specific Gravity");

        setSize(700, 700);                      //setting up the window

        GridBagLayout      gridbag     = new GridBagLayout();
        GridBagConstraints constraints = new GridBagConstraints();
        JPanel             pane        = new JPanel();

        pane.setLayout(gridbag);

        myday  = new EnterDay(this);            //creating instances of the four helper classes
        mylist = new ListDay(this);
        myedit = new EditDay(this);
        myshow = new ShowGraph(this);

// GridBag constraints for the main panel (pane)--set up as a for-loop to avoid too much duplication of code
        int[]    constraints1str = { 0, 1, 2, 3 };
        int[]    constraints2str = { 8, 5, 5, 60 };
        JPanel[] firstvarstr     = { myday, mylist, myedit, myshow };    //puts instance of each helper class
                                                                         //into a panel
        for (int i = 0; i < 4; i++) {
            buildConstraints(constraints, 0, constraints1str[i], 1, 1, 100,
                             constraints2str[i]);

            constraints.fill = GridBagConstraints.BOTH;

            gridbag.setConstraints(firstvarstr[i], constraints);
            pane.add(firstvarstr[i]);
        }

        setContentPane(pane);                   //making everything visible   
        show();
    }

    public static void main(String[] arguments) {

        JFrame     frame = new SpecificGravityProgram();    //to start it all
        ExitWindow exit  = new ExitWindow();                //to stop it all

        frame.addWindowListener(exit);
        frame.setVisible(true);
    }

// To update the textarea and graph when a user enters a date/time/value
    void update(EnterDay control)    //there's only one component set up with an ActionListener in Enterday--the button,
                                     //which is because *all* fields/boxes need to be set and entered before continuing
    {

        if (control == myday) {
            if (myday.enterplatofield.getText().equals("")) {               //if the textbox is empty
                return;
            } else {
                try {
                    Double.parseDouble(myday.enterplatofield.getText());    //or has a value that isn't a number
                } catch (NumberFormatException e) {
                    return;
                }

                if (myday.monthbox.getSelectedIndex() == 1) {           //The following section is preliminary to the 
                    figuremonths = 744;                                 //graph--I needed to figure the number of hours 
                } else if (myday.monthbox.getSelectedIndex() == 2) {    //between entry number one and two, two and three,
                    figuremonths = 1416;                                //etc.  I'm sure there's a way to do it with 
                } else if (myday.monthbox.getSelectedIndex() == 3) {    //Calendar and/or Date, but I got frustrated with 
                    figuremonths = 2160;                                //them and decided to just do it on my own.  <G>
                } else if (myday.monthbox.getSelectedIndex() == 4) {
                    figuremonths = 2880;
                } else if (myday.monthbox.getSelectedIndex() == 5) {
                    figuremonths = 3624;
                } else if (myday.monthbox.getSelectedIndex() == 6) {
                    figuremonths = 4344;
                } else if (myday.monthbox.getSelectedIndex() == 7) {
                    figuremonths = 5088;
                } else if (myday.monthbox.getSelectedIndex() == 8) {
                    figuremonths = 5832;
                } else if (myday.monthbox.getSelectedIndex() == 9) {
                    figuremonths = 6552;
                } else if (myday.monthbox.getSelectedIndex() == 10) {
                    figuremonths = 7296;
                } else if (myday.monthbox.getSelectedIndex() == 11) {
                    figuremonths = 8016;
                }

                if (myday.yearbox.getSelectedIndex() == 1) {
                    figureyears = 8760;
                } else if (myday.yearbox.getSelectedIndex() == 2) {
                    figureyears = 17520;
                } else if (myday.yearbox.getSelectedIndex() == 3) {
                    figureyears = 26280;
                } else if (myday.yearbox.getSelectedIndex() == 4) {
                    figureyears = 35064;
                } else if (myday.yearbox.getSelectedIndex() == 5) {
                    figureyears = 43824;
                } else if (myday.yearbox.getSelectedIndex() == 6) {
                    figureyears = 52584;
                } else if (myday.yearbox.getSelectedIndex() == 7) {
                    figureyears = 61344;
                } else if (myday.yearbox.getSelectedIndex() == 8) {
                    figureyears = 70128;
                } else if (myday.yearbox.getSelectedIndex() == 9) {
                    figureyears = 78888;
                }

                                                                            //figuring in leap years...
                int testforleap = myday.yearbox.getSelectedIndex();

                if ((testforleap != 3) && (testforleap != 7)) {
                    figurehours = ((myday.timebox.getSelectedIndex())
                                   + (myday.daybox.getSelectedIndex() * 24)
                                   + figuremonths + figureyears);
                } else if (myday.monthbox.getSelectedIndex() > 1) {
                    figurehours = ((myday.timebox.getSelectedIndex())
                                   + (myday.daybox.getSelectedIndex() * 24)
                                   + figuremonths + 24 + figureyears);
                } else {
                    figurehours = ((myday.timebox.getSelectedIndex())
                                   + (myday.daybox.getSelectedIndex() * 24)
                                   + figuremonths + figureyears);
                }

                String figurehoursstr = String.valueOf(figurehours);

                if (myday.spgrbox.getSelectedIndex() == 0)                  //if spgrbox is set to Specific Gravity
                {
                    String s1 = myday.enterplatofield.getText();

                    spgr  = Double.parseDouble(s1);
                    plato = (spgr * spgr * -205.347) + (668.7183 * spgr)
                            - 463.371;

                    String platovec = String.valueOf(plato);
                    String spgrvec  = String.valueOf(spgr);                 //convert the number in the textbox to Plato

                    graphy = 180 - ((spgr - 1) * 2000);

                    String graphystr = String.valueOf(graphy);

                    editint = editintarr[0];                                //starts out the first time as 0, progressively ++, 
                                                                            //progressively ++, but will be set to an 
                                                                            //entirely new value if the editmefield is used
                    Vector[]    allofemvec    = { entermonthvec, enterdayvec, 
                                                  entertimevec,  enteryearvec, 
                                                  enterplatovec, enterspgrvec, 
                                                  spgrboxvec, figurehoursvec, graphyvec};
                    Vector[]    partialvec    = { entermonthvec, enterdayvec,
                                                  entertimevec, enteryearvec,
                                                  spgrboxvec };
                    JComboBox[] boxesarr      = { myday.monthbox,
                                                  myday.daybox, myday.timebox,
                                                  myday.yearbox,
                                                  myday.spgrbox };
                    int         howmanyfornow = entermonthvec.size();

                    if (howmanyfornow > editint) {
                        for (int i = 0; i < 9; i++) {                   //if a line is being edited, removes the old line 
                            allofemvec[i].removeElementAt(editint);
                        }
                    }

                    for (int i = 0; i < 5; i++) {
                        partialvec[i]
                            .insertElementAt(boxesarr[i].getSelectedItem(),
                                             editint);                  //enters the new line, either at the end
                    }                                                   //of the vectors, or at the position of
                    enterplatovec.insertElementAt(platovec, editint);   //the line being edited
                    enterspgrvec.insertElementAt(spgrvec, editint);
                    figurehoursvec.insertElementAt(figurehoursstr, editint);
                    graphyvec.insertElementAt(graphystr, editint);

                    int howmany   = entermonthvec.size();
                    int howminus  = howmany - 1;
                    int testzeroa =
                        Integer.parseInt((String) figurehoursvec
                            .elementAt(0));                            //to make sure in the next step, 
                    int testzerob =                                    //we're not dividing by 0
                        Integer.parseInt((String) figurehoursvec
                            .elementAt(howminus));                     

                    if (testzeroa == testzerob) {
                        graphindex = 0;
                    } else {
                        graphindex =
                            (620
                             / (Integer.parseInt((String) figurehoursvec.elementAt(howminus))
                                - Integer.parseInt((String) figurehoursvec.elementAt(0))));
                    }

                                                    //graphindex will be used to set the x coordinates--I want the graph
                                                    //to fill the whole graphics area, no matter how many points
                    graphxvec.removeAllElements();                          //erase the old set of x coordinates...

                    for (int i = 0; i < howmany; i++) {
                        graphx =
                            (70 + graphindex
                             * (Integer.parseInt((String) figurehoursvec.elementAt(i))
                                - Integer
                                    .parseInt((String) figurehoursvec
                                        .elementAt(0))));

                        String graphxstr = String.valueOf(graphx);

                        graphxvec.insertElementAt(graphxstr, i);            //...to replace with the new.
                    }

                    editint       = (howmany);                 //reset all the variables to reflect the new vector size
                    editintarr[0] = editint;

                    mylist.value.setText(" ");

// To display the lines in the textarea; I want to "truncate" the doubles to a readable length, but
// sometimes there aren't enough characters to fill a substring of a certain length
                    for (int i = 0; i < howmany; i++) {
                        if ((((String) enterspgrvec.elementAt(i))
                                .length() < 5) && (((String) enterplatovec
                                .elementAt(i)).length() < 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(i))
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(i))
                                + "\n ");
                        } else if ((((String) enterspgrvec.elementAt(i))
                                .length() < 5) && (((String) enterplatovec
                                .elementAt(i)).length() >= 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(i))
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(
                                i)).substring(0, 5) + "\n ");
                        } else if ((((String) enterspgrvec.elementAt(i))
                                .length() >= 5) && (((String) enterplatovec
                                .elementAt(i)).length() < 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(
                                i)).substring(0, 5)
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(i))
                                + "\n ");
                        } else {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(
                                i)).substring(0, 5)
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(
                                i)).substring(0, 5) + "\n ");
                        }

                        myday.enterplatofield.setText("");
                    }

                    repaint();

                    return;
                } else if (myday.spgrbox.getSelectedIndex() == 1)           //if spgrbox is set to Specific Gravity
                {
                    String s2 = myday.enterplatofield.getText();

                    plato = Double.parseDouble(s2);
                    spgr  = (plato / (258.6 - (plato / 258.6 * 227.1)) + 1);

                    String platovec = String.valueOf(plato);                //convert the number in the textbox to Plato
                    String spgrvec  = String.valueOf(spgr);

                    graphy = 180 - ((spgr - 1) * 2000);

                    String graphystr = String.valueOf(graphy);

                    editint = editintarr[0];                           //starts out the first time as 0, progressively ++, 
                                                                       //but will be set to an entirely new value if 
                                                                       //the editmefield is used
                    Vector[]    allofemvec    = { entermonthvec, enterdayvec, 
                                                  entertimevec, enteryearvec, 
                                                  enterplatovec, enterspgrvec, 
                                                  spgrboxvec, figurehoursvec, graphyvec };
                    Vector[]    partialvec    = { entermonthvec, enterdayvec,
                                                  entertimevec, enteryearvec,
                                                  spgrboxvec };
                    JComboBox[] boxesarr      = { myday.monthbox,
                                                  myday.daybox, myday.timebox,
                                                  myday.yearbox,
                                                  myday.spgrbox };
                    int         howmanyfornow = entermonthvec.size();

                    if (howmanyfornow > editint) {
                        for (int i = 0; i < 9; i++) {                    //if a line is being edited, removes the old line 
                            allofemvec[i].removeElementAt(editint);
                        }
                    }

                    for (int i = 0; i < 5; i++) {
                        partialvec[i]
                            .insertElementAt(boxesarr[i].getSelectedItem(),
                                             editint);                      //enters the new line, either at the end
                    }                                                       //of the vectors, or at the position of        
                    enterplatovec.insertElementAt(platovec, editint);       //the line being edited
                    enterspgrvec.insertElementAt(spgrvec, editint);
                    figurehoursvec.insertElementAt(figurehoursstr, editint);
                    graphyvec.insertElementAt(graphystr, editint);

                    int howmany   = entermonthvec.size();
                    int howminus  = howmany - 1;
                    int testzeroa =
                        Integer.parseInt((String) figurehoursvec
                            .elementAt(0));                                 //to make sure in the next step, 
                    int testzerob =
                        Integer.parseInt((String) figurehoursvec
                            .elementAt(howminus));                          //we're not dividing by 0

                    if (testzeroa == testzerob) {
                        graphindex = 0;
                    } else {
                        graphindex =
                            (620
                             / (Integer.parseInt((String) figurehoursvec.elementAt(howminus))
                                - Integer.parseInt((String) figurehoursvec.elementAt(0))));
                    }

                                                    //graphindex will be used to set the x coordinates--I want the graph
                                                    //to fill the whole graphics area, no matter how many points
                    graphxvec.removeAllElements();                          //erase the old set of x coordinates...

                    for (int i = 0; i < howmany; i++) {
                        graphx =
                            (70 + graphindex
                             * (Integer.parseInt((String) figurehoursvec.elementAt(i))
                                - Integer
                                    .parseInt((String) figurehoursvec
                                        .elementAt(0))));

                        String graphxstr = String.valueOf(graphx);

                        graphxvec.insertElementAt(graphxstr, i);            //...to replace with the new.
                    }

                    editint       = (howmany);                   //reset all the variables to reflect the new vector size
                    editintarr[0] = editint;

                    mylist.value.setText(" ");

//  To display the lines in the textarea; I want to "truncate" the doubles to a readable length, but
//sometimes there aren't enough characters to fill a substring of a certain length
                    for (int i = 0; i < howmany; i++) {
                        if ((((String) enterspgrvec.elementAt(i))
                                .length() < 5) && (((String) enterplatovec
                                .elementAt(i)).length() < 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(i))
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(i))
                                + "\n ");
                        } else if ((((String) enterspgrvec.elementAt(i))
                                .length() < 5) && (((String) enterplatovec
                                .elementAt(i)).length() >= 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(i))
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(
                                i)).substring(0, 5) + "\n ");
                        } else if ((((String) enterspgrvec.elementAt(i))
                                .length() >= 5) && (((String) enterplatovec
                                .elementAt(i)).length() < 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(
                                i)).substring(0, 5)
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(i))
                                + "\n ");
                        } else {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(
                                i)).substring(0, 5)
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(
                                i)).substring(0, 5) + "\n ");
                        }

                        myday.enterplatofield.setText("");
                    }

                    repaint();

                    return;
                }
            }
        }
    }

// To update the textarea and graph when a user chooses Edit, Delete, Save, or Load
    void update(EditDay control)                    // Edit, Delete, Save, or Load
    {

        if (control == myedit) {
            if (myedit.editbuttonint == 1) {        //loadmebutton
                if (myedit.loadmefield.getText().equals("")) {              //if there's nothing in the loadmefield
                    return;
                } else {
                    try {
                        String stringfilein = myedit.loadmefield.getText();

// sets up the loadme objects; I wanted to put these in a for-loop, but I had a problem in logic--I couldn't put
// the FileInputStream objects into an array, to go into a loop that was set up to create them, because they didn't 
// exist yet!  If anyone has a suggestion for me, I'm all ears!           
                        FileInputStream   howmanyfilein     =
                            new FileInputStream(stringfilein + "howmany.brw");
                        int               howmany           =
                            howmanyfilein.read();
                        FileInputStream   entermonthfilein  =
                            new FileInputStream(stringfilein + "month.brw");
                        ObjectInputStream entermonthobjin   =
                            new ObjectInputStream(entermonthfilein);
                        FileInputStream   enterdayfilein    =
                            new FileInputStream(stringfilein + "day.brw");
                        ObjectInputStream enterdayobjin     =
                            new ObjectInputStream(enterdayfilein);
                        FileInputStream   entertimefilein   =
                            new FileInputStream(stringfilein + "time.brw");
                        ObjectInputStream entertimeobjin    =
                            new ObjectInputStream(entertimefilein);
                        FileInputStream   enteryearfilein   =
                            new FileInputStream(stringfilein + "year.brw");
                        ObjectInputStream enteryearobjin    =
                            new ObjectInputStream(enteryearfilein);
                        FileInputStream   enterplatofilein  =
                            new FileInputStream(stringfilein + "plato.brw");
                        ObjectInputStream enterplatoobjin   =
                            new ObjectInputStream(enterplatofilein);
                        FileInputStream   enterspgrfilein   =
                            new FileInputStream(stringfilein + "spgr.brw");
                        ObjectInputStream enterspgrobjin    =
                            new ObjectInputStream(enterspgrfilein);
                        FileInputStream   spgrboxfilein     =
                            new FileInputStream(stringfilein + "box.brw");
                        ObjectInputStream spgrboxobjin      =
                            new ObjectInputStream(spgrboxfilein);
                        FileInputStream   figurehoursfilein =
                            new FileInputStream(stringfilein + "figure.brw");
                        ObjectInputStream figurehoursobjin  =
                            new ObjectInputStream(figurehoursfilein);
                        FileInputStream   xfilein           =
                            new FileInputStream(stringfilein + "x.brw");
                        ObjectInputStream xobjin            =
                            new ObjectInputStream(xfilein);
                        FileInputStream   yfilein           =
                            new FileInputStream(stringfilein + "y.brw");
                        ObjectInputStream yobjin            =
                            new ObjectInputStream(yfilein);

       // adds the information from the saved files back into the vectors
                        Vector[]            vectorarr   = {
                            entermonthvec, enterdayvec, entertimevec,
                            enteryearvec, enterplatovec, enterspgrvec,
                            spgrboxvec, figurehoursvec, graphxvec, graphyvec
                        };
                        FileInputStream[]   inputarr    = {
                            entermonthfilein, enterdayfilein, entertimefilein,
                            enteryearfilein, enterplatofilein,
                            enterspgrfilein, spgrboxfilein, figurehoursfilein,
                            xfilein, yfilein
                        };
                        ObjectInputStream[] objinputarr = {
                            entermonthobjin, enterdayobjin, entertimeobjin,
                            enteryearobjin, enterplatoobjin, enterspgrobjin,
                            spgrboxobjin, figurehoursobjin, xobjin, yobjin
                        };

                        for (int i = 0; i < 10; i++) {
                            vectorarr[i].removeAllElements();

                            for (int j = 0; j < howmany; j++) {
                                vectorarr[i]
                                    .addElement(objinputarr[i].readObject());
                            }

                            objinputarr[i].close();
                        }

                        editintarr[0] = entermonthvec.size();               //resets the value of editintarr[0] to 
                                                                            //the total size of the vectors

                        mylist.value.setText("");

// To display the lines in the textarea; I want to "truncate" the doubles to a readable length, but
//sometimes there aren't enough characters to fill a substring of a certain length
                        howmany = entermonthvec.size();

                        int howminus = entermonthvec.size() - 1;

                        for (int i = 0; i < howmany; i++) {
                            if ((((String) enterspgrvec.elementAt(i))
                                    .length() < 5) && (((String) enterplatovec
                                    .elementAt(i)).length() < 5)) {
                                mylist.value.append(
                                    (i + 1) + ") "
                                    + ((String) entermonthvec.elementAt(i))
                                    + " "
                                    + ((String) enterdayvec.elementAt(i))
                                    + ", "
                                    + ((String) enteryearvec.elementAt(i))
                                    + ", "
                                    + ((String) entertimevec.elementAt(i))
                                    + ".      Specific Gravity = "
                                    + ((String) enterspgrvec.elementAt(i))
                                    + ";      Degrees Plato = "
                                    + ((String) enterplatovec.elementAt(i))
                                    + "\n ");
                            } else if ((((String) enterspgrvec.elementAt(i))
                                    .length() < 5) && (((String) enterplatovec
                                    .elementAt(i)).length() >= 5)) {
                                mylist.value.append(
                                    (i + 1) + ") "
                                    + ((String) entermonthvec.elementAt(i))
                                    + " "
                                    + ((String) enterdayvec.elementAt(i))
                                    + ", "
                                    + ((String) enteryearvec.elementAt(i))
                                    + ", "
                                    + ((String) entertimevec.elementAt(i))
                                    + ".      Specific Gravity = "
                                    + ((String) enterspgrvec.elementAt(i))
                                    + ";      Degrees Plato = "
                                    + ((String) enterplatovec.elementAt(
                                    i)).substring(0, 5) + "\n ");
                            } else if ((((String) enterspgrvec.elementAt(i))
                                    .length() >= 5) && (((String) enterplatovec
                                    .elementAt(i)).length() < 5)) {
                                mylist.value.append(
                                    (i + 1) + ") "
                                    + ((String) entermonthvec.elementAt(i))
                                    + " "
                                    + ((String) enterdayvec.elementAt(i))
                                    + ", "
                                    + ((String) enteryearvec.elementAt(i))
                                    + ", "
                                    + ((String) entertimevec.elementAt(i))
                                    + ".      Specific Gravity = "
                                    + ((String) enterspgrvec.elementAt(
                                    i)).substring(0, 5)
                                    + ";      Degrees Plato = "
                                    + ((String) enterplatovec.elementAt(i))
                                    + "\n ");
                            } else {
                                mylist.value.append(
                                    (i + 1) + ") "
                                    + ((String) entermonthvec.elementAt(i))
                                    + " "
                                    + ((String) enterdayvec.elementAt(i))
                                    + ", "
                                    + ((String) enteryearvec.elementAt(i))
                                    + ", "
                                    + ((String) entertimevec.elementAt(i))
                                    + ".      Specific Gravity = "
                                    + ((String) enterspgrvec.elementAt(
                                    i)).substring(0, 5)
                                    + ";      Degrees Plato = "
                                    + ((String) enterplatovec.elementAt(
                                    i)).substring(0, 5) + "\n ");
                            }
                        }

                        myday.monthbox
                            .setSelectedItem(entermonthvec
                                .elementAt(howminus));                      //changes the dropdowns to the
                        myday.daybox                                        //values of the last line entered
                            .setSelectedItem(enterdayvec.elementAt(howminus));    
                        myday.timebox
                            .setSelectedItem(entertimevec
                                .elementAt(howminus));
                        myday.yearbox
                            .setSelectedItem(enteryearvec
                                .elementAt(howminus));
                        myday.spgrbox
                            .setSelectedItem(spgrboxvec.elementAt(howminus));
                        myedit.loadmefield.setText("");
                        repaint();
                    } catch (Exception e) {
                        return;
                    }
                }
            } else if (myedit.editbuttonint == 2) {                         //savemebutton
                if (myedit.savemefield.getText().equals("")) {              //if there's nothing in the loadmefield
                    return;
                } else {
                    try {

// sets up the loadme objects; I wanted to put these in a for-loop, but I had the same problem in logic as above--I couldn't put
// the FileInputStream objects into an array, to go into a loop that was set up to create them, because they didn't 
// exist yet!  If anyone has a suggestion for me, I'm all ears!           
                        int                howmany         =
                            entermonthvec.size();
                        String             stringfileout   =
                            myedit.savemefield.getText();
                        FileOutputStream   entermonthfile  =
                            new FileOutputStream(stringfileout + "month.brw");
                        ObjectOutputStream entermonthobj   =
                            new ObjectOutputStream(entermonthfile);
                        FileOutputStream   enterdayfile    =
                            new FileOutputStream(stringfileout + "day.brw");
                        ObjectOutputStream enterdayobj     =
                            new ObjectOutputStream(enterdayfile);
                        FileOutputStream   entertimefile   =
                            new FileOutputStream(stringfileout + "time.brw");
                        ObjectOutputStream entertimeobj    =
                            new ObjectOutputStream(entertimefile);
                        FileOutputStream   enteryearfile   =
                            new FileOutputStream(stringfileout + "year.brw");
                        ObjectOutputStream enteryearobj    =
                            new ObjectOutputStream(enteryearfile);
                        FileOutputStream   enterplatofile  =
                            new FileOutputStream(stringfileout + "plato.brw");
                        ObjectOutputStream enterplatoobj   =
                            new ObjectOutputStream(enterplatofile);
                        FileOutputStream   enterspgrfile   =
                            new FileOutputStream(stringfileout + "spgr.brw");
                        ObjectOutputStream enterspgrobj    =
                            new ObjectOutputStream(enterspgrfile);
                        FileOutputStream   spgrboxfile     =
                            new FileOutputStream(stringfileout + "box.brw");
                        ObjectOutputStream spgrboxobj      =
                            new ObjectOutputStream(spgrboxfile);
                        FileOutputStream   figurehoursfile =
                            new FileOutputStream(stringfileout
                                                 + "figure.brw");
                        ObjectOutputStream figurehoursobj  =
                            new ObjectOutputStream(figurehoursfile);
                        FileOutputStream   xfile           =
                            new FileOutputStream(stringfileout + "x.brw");
                        ObjectOutputStream xobj            =
                            new ObjectOutputStream(xfile);
                        FileOutputStream   yfile           =
                            new FileOutputStream(stringfileout + "y.brw");
                        ObjectOutputStream yobj            =
                            new ObjectOutputStream(yfile);

         //writes information in the vectors into the savefiles           
                        Vector[]             vectorarr    = {
                            entermonthvec, enterdayvec, entertimevec,
                            enteryearvec, enterplatovec, enterspgrvec,
                            spgrboxvec, figurehoursvec, graphxvec, graphyvec
                        };
                        ObjectOutputStream[] objoutputarr = {
                            entermonthobj, enterdayobj, entertimeobj,
                            enteryearobj, enterplatoobj, enterspgrobj,
                            spgrboxobj, figurehoursobj, xobj, yobj
                        };

                        for (int i = 0; i < 10; i++) {
                            for (int j = 0; j < howmany; j++) {
                                objoutputarr[i]
                                    .writeObject(vectorarr[i].elementAt(j));
                            }

                            objoutputarr[i].close();
                        }

                        FileOutputStream howmanyfile =
                            new FileOutputStream(stringfileout
                                                 + "howmany.brw");

                        howmanyfile.write(howmany);
                        howmanyfile.close();
                        myedit.savemefield.setText("");
                    } catch (Exception e) {
                        System.out.println("Error -- " + e.toString());
                    }
                }
            } else if (myedit.editbuttonint == 3) {                         //needseditbutton
                if (myedit.needseditfield.getText().equals("")) {           //if needseditfield is empty
                    return;
                } else {
                    try {
                        Integer.parseInt(myedit.needseditfield.getText());  //or not a number
                    } catch (NumberFormatException e) {
                        return;
                    }

                    {
                        int editint =
                            (Integer.parseInt(myedit.needseditfield.getText())
                             - 1);                                          //or of a value that doesn't
                                                                            //correspond to a line number
                        if (editint > (entermonthvec.size() - 1)) {
                            return;
                        } else if (editint < 0) {
                            return;
                        } else {
                            editintarr[0] = editint;

                            myday.monthbox
                                .setSelectedItem(entermonthvec
                                    .elementAt(editint));                  //changes the dropdown and textbox to the
                            myday.daybox                                   //values of the selected line-to-be-edited
                                .setSelectedItem(enterdayvec
                                    .elementAt(editint));    
                            myday.timebox
                                .setSelectedItem(entertimevec
                                    .elementAt(editint));
                            myday.yearbox
                                .setSelectedItem(enteryearvec
                                    .elementAt(editint));
                            myday.spgrbox
                                .setSelectedItem(spgrboxvec
                                    .elementAt(editint));

                            String checkitout =
                                (String) spgrboxvec.elementAt(editint);

                            if ("Specific Gravity".equals(checkitout)) {
                                myday.enterplatofield
                                    .setText((String) enterspgrvec
                                        .elementAt(editint));               //if the original entry was in
                            }                                               //spgr, the editline will be displayed
                                                                            //in spgr; otherwise in plato
                            
                            else {
                                myday.enterplatofield
                                    .setText((String) enterplatovec
                                        .elementAt(editint));
                            }

                            myedit.needseditfield.setText("");
                        }
                    }
                }
            } else if (myedit.editbuttonint == 4) {                         //needsdeletebutton   
                if (myedit.needsdeletefield.getText().equals("")) {         //if needsdeletefield is empty
                    return;
                } else {
                    try {
                        Integer.parseInt(myedit.needsdeletefield.getText()); //or not a number
                    } catch (NumberFormatException e) {
                        return;
                    }

                    int deleteint =
                        (Integer.parseInt(myedit.needsdeletefield.getText())
                         - 1);                                              //or of a value that doesn't
                                                                            //correspond to a line number
                    if (deleteint > (entermonthvec.size() - 1)) {
                        return;
                    } else if (deleteint < 0) {
                        return;
                    } else {
                        Vector[] allofemvec = {
                            entermonthvec, enterdayvec, entertimevec,
                            enteryearvec, enterplatovec, enterspgrvec,
                            spgrboxvec, figurehoursvec, graphyvec
                        };

                        for (int i = 0; i < 9; i++) {                       //deletes value at line number from all vectors
                            allofemvec[i].removeElementAt(deleteint);
                        }
                    }

// To display the lines in the textarea; I want to "truncate" the doubles to a readable length, but
//sometimes there aren't enough characters to fill a substring of a certain length
                    int howmany  = entermonthvec.size();
                    int howminus = entermonthvec.size() - 1;

                    mylist.value.setText("");

                    for (int i = 0; i < howmany; i++) {
                        if ((((String) enterspgrvec.elementAt(i))
                                .length() < 5) && (((String) enterplatovec
                                .elementAt(i)).length() < 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(i))
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(i))
                                + "\n ");
                        } else if ((((String) enterspgrvec.elementAt(i))
                                .length() < 5) && (((String) enterplatovec
                                .elementAt(i)).length() >= 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(i))
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(
                                i)).substring(0, 5) + "\n ");
                        } else if ((((String) enterspgrvec.elementAt(i))
                                .length() >= 5) && (((String) enterplatovec
                                .elementAt(i)).length() < 5)) {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(
                                i)).substring(0, 5)
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(i))
                                + "\n ");
                        } else {
                            mylist.value.append(
                                (i + 1) + ") "
                                + ((String) entermonthvec.elementAt(i)) + " "
                                + ((String) enterdayvec.elementAt(i)) + ", "
                                + ((String) enteryearvec.elementAt(i)) + ", "
                                + ((String) entertimevec.elementAt(i))
                                + ".      Specific Gravity = "
                                + ((String) enterspgrvec.elementAt(
                                i)).substring(0, 5)
                                + ";      Degrees Plato = "
                                + ((String) enterplatovec.elementAt(
                                i)).substring(0, 5) + "\n ");
                        }
                    }

                    myedit.needsdeletefield.setText("");

                    editintarr[0] = entermonthvec.size();
                }
            }
        }
    }
}

// In EnterDay, the time/day/density values are accepted from the user.
class EnterDay extends JPanel implements ActionListener                     // first helper class
{

    SpecificGravityProgram frame;                                           //references parent class
    JLabel                 month           =
        new JLabel("Choose Date and Time:  ");                              //creating instances of all the components
    JComboBox              monthbox        = new JComboBox();
    JComboBox              daybox          = new JComboBox();
    JComboBox              yearbox         = new JComboBox();
    JComboBox              timebox         = new JComboBox();
    JLabel                 enterplato      = new JLabel("Enter Reading:  ");
    JTextField             enterplatofield = new JTextField(15);
    JComboBox              spgrbox         = new JComboBox();
    JButton                pushme          = new JButton("Push Me Hard!");
    String[]               montharr        = {
        "January", "February", "March", "April", "May", "June", "July",
        "August", "September", "October", "November", "December"
    };
    String[]               timearr         = {
        "midnight", "1:00 A.M.", "2:00 A.M.", "3:00 A.M.", "4:00 A.M.",
        "5:00 A.M.", "6:00 A.M.", "7:00 A.M.", "8:00 A.M.", "9:00 A.M.",
        "10:00 A.M.", "11:00 A.M.", "noon", "1:00 P.M.", "2:00 P.M.",
        "3:00 P.M.", "4:00 P.M.", "5:00 P.M.", "6:00 P.M.", "7:00 P.M.",
        "8:00 P.M.", "9:00 P.M.", "10:00 P.M.", "11:00 P.M."
    };
    String[]               yeararr         = {
        "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008",
        "2009", "2010"
    };

// constructor for GridBagConstraints 
    void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw,
                          int gh, int wx, int wy) {

        gbc.gridx      = gx;
        gbc.gridy      = gy;
        gbc.gridwidth  = gw;
        gbc.gridheight = gh;
        gbc.weightx    = wx;
        gbc.weighty    = wy;
    }

    EnterDay(SpecificGravityProgram parent)                                 //constructor method--references parent
    {

        frame = parent;

        setSize(700, 100);                                                  //setting up panel

        GridBagLayout      enterdaybag = new GridBagLayout();
        GridBagConstraints constraints = new GridBagConstraints();

        setLayout(enterdaybag);

        for (int i = 0; i < 12; i++) {                                      //setting up comboboxes
            monthbox.addItem(montharr[i]);
        }

        for (int i = 1; i < 32; i++) {
            String daynumb = String.valueOf(i);

            daybox.addItem(daynumb);
        }

        for (int i = 0; i < 24; i++) {
            timebox.addItem(timearr[i]);
        }

        for (int i = 0; i < 10; i++) {
            yearbox.addItem(yeararr[i]);
        }

        spgrbox.addItem("Specific Gravity");
        spgrbox.addItem("Degrees Plato");
        pushme.addActionListener(this);                     //the one ActionListener in this class--I don't want any of
                                                            //the other components to be "actable"--date/time/density must
                                                            //*all* be entered before action is taken.
        
//setting up GridBag for this panel        
        int[]        c1          = {
            0, 1, 2, 3, 4, 0, 1, 3, 7
        };    
        int[]        c2          = {
            0, 0, 0, 0, 0, 1, 1, 1, 1
        };
        int[]        c3          = {
            1, 1, 1, 1, 1, 1, 2, 2, 1
        };
        int[]        lr          = {
            GridBagConstraints.NONE, GridBagConstraints.NONE,
            GridBagConstraints.NONE, GridBagConstraints.NONE,
            GridBagConstraints.NONE, GridBagConstraints.NONE,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NONE,
            GridBagConstraints.NONE
        };
        int[]        compass     = {
            GridBagConstraints.EAST, GridBagConstraints.EAST,
            GridBagConstraints.EAST, GridBagConstraints.EAST,
            GridBagConstraints.CENTER, GridBagConstraints.EAST,
            GridBagConstraints.EAST, GridBagConstraints.WEST,
            GridBagConstraints.CENTER
        };
        JComponent[] restofstuff = {
            month, monthbox, daybox, yearbox, timebox, enterplato,
            enterplatofield, spgrbox, pushme
        };

        for (int i = 0; i < 9; i++) {
            buildConstraints(constraints, c1[i], c2[i], c3[i], 1, 100, 100);

            constraints.fill   = lr[i];
            constraints.anchor = compass[i];

            enterdaybag.setConstraints(restofstuff[i], constraints);
            add(restofstuff[i]);
        }
    }

    public void actionPerformed(ActionEvent evt)                            //if button gets pushed, go above to update()
    {

        if (evt.getSource() instanceof JButton) {
            frame.update(this);
        }
    }
}

// In ListDay, the time/day/density values are listed in the textarea.
class ListDay extends JPanel                                                //second helper class
{

    SpecificGravityProgram frame;                                           //references parent class
    JTextArea              value       = new JTextArea(14, 50);             //creating instance of only component, 
    JScrollPane            scrollvalue =                                    //and setting up scrollbar on it 
        new JScrollPane(value,
                        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ListDay(SpecificGravityProgram parent)                                  //constructor method--references parent
    {

        frame = parent;

        value.setEditable(false);              //not much to this one--doesn't do anything but display--I had originally 
        add(scrollvalue);                      //intended this to be in "interactive" textarea, but decided it worked best
                                               //as setEditable(false).      
    }
}

// In EditDay, the user can choose to manipulate already existing data--edit, delete, load or save.
class EditDay extends JPanel implements ActionListener                      //third helper class
{

    SpecificGravityProgram frame;                                           //references parent class
    JLabel                 needsdelete       =
        new JLabel("Shucks!  Delete that line!   ");                        //creating instances of components
    JTextField             needsdeletefield  = new JTextField(10);
    JButton                needsdeletebutton = new JButton("Delete!!!!");
    JLabel                 needsedit         =
        new JLabel("Oops!  I need to edit a line!   ");
    JTextField             needseditfield    = new JTextField(10);
    JButton                needseditbutton   = new JButton("Edit!!!!");
    JLabel                 saveme            = new JLabel("Save File:   ");
    JTextField             savemefield       = new JTextField(15);
    JButton                savemebutton      = new JButton("Save Me!");
    JLabel                 loadme            = new JLabel("Load File:   ");
    JTextField             loadmefield       = new JTextField(15);
    JButton                loadmebutton      = new JButton("Load Me Up!");
    int                    editbuttonint;                       //used to determine which button/field has been acted upon

//constructor for GridBagConstraints
    void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw,
                          int gh, int wx, int wy) {

        gbc.gridx      = gx;
        gbc.gridy      = gy;
        gbc.gridwidth  = gw;
        gbc.gridheight = gh;
        gbc.weightx    = wx;
        gbc.weighty    = wy;
    }

    EditDay(SpecificGravityProgram parent)                                  //constructor method--references parent
    {

        frame = parent;

        GridBagLayout      editdaybag  = new GridBagLayout();               //setting up panel
        GridBagConstraints constraints = new GridBagConstraints();

        setLayout(editdaybag);
        needsdeletefield.addActionListener(this);
        needsdeletebutton.addActionListener(this);
        needseditfield.addActionListener(this);                             //adds ActionListener to all four buttons and
        needseditbutton.addActionListener(this);                            //all four fields
        savemefield.addActionListener(this);
        savemebutton.addActionListener(this);
        loadmefield.addActionListener(this);
        loadmebutton.addActionListener(this);

//setting up GridBag for this panel
        int[]        c1          = {
            0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2
        };    
        int[]        c2          = {
            0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3
        };
        int[]        c3          = {
            100, 30, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };
        int[]        compass     = {
            GridBagConstraints.EAST, GridBagConstraints.WEST,
            GridBagConstraints.WEST, GridBagConstraints.EAST,
            GridBagConstraints.WEST, GridBagConstraints.WEST,
            GridBagConstraints.EAST, GridBagConstraints.WEST,
            GridBagConstraints.WEST, GridBagConstraints.EAST,
            GridBagConstraints.WEST, GridBagConstraints.WEST
        };
        JComponent[] restofstuff = {
            needsdelete, needsdeletefield, needsdeletebutton, needsedit,
            needseditfield, needseditbutton, saveme, savemefield,
            savemebutton, loadme, loadmefield, loadmebutton
        };

        for (int i = 0; i < 12; i++) {
            buildConstraints(constraints, c1[i], c2[i], 1, 1, c3[i], 100);

            constraints.fill   = GridBagConstraints.NONE;
            constraints.anchor = compass[i];

            editdaybag.setConstraints(restofstuff[i], constraints);
            add(restofstuff[i]);
        }
    }

    public void actionPerformed(ActionEvent evt)                //sets editbuttonint, depending on which field/button is 
    {                                                           //pushed--this gets used above, in update()

        if (evt.getSource() instanceof JButton)    
        {
            if (evt.getSource() == loadmebutton) {
                editbuttonint = 1;
            } else if (evt.getSource() == savemebutton) {
                editbuttonint = 2;
            } else if (evt.getSource() == needseditbutton) {
                editbuttonint = 3;
            } else if (evt.getSource() == needsdeletebutton) {
                editbuttonint = 4;
            }
        } else if (evt.getSource() instanceof JTextField) {
            if (evt.getSource() == loadmefield) {
                editbuttonint = 1;
            } else if (evt.getSource() == savemefield) {
                editbuttonint = 2;
            } else if (evt.getSource() == needseditfield) {
                editbuttonint = 3;
            } else if (evt.getSource() == needsdeletefield) {
                editbuttonint = 4;
            }
        }

        frame.update(this);
    }
}

// ShowGraph is where the graphics is done--the graph is drawn here.
class ShowGraph extends JPanel                                              //fourth (and last, but not least!) helper class
{

    SpecificGravityProgram frame;                                           //references parent
    int                    counting;                            //will be = total number of values in the graphxvec vector

    ShowGraph(SpecificGravityProgram parent)                                //constructor method, references parent
    {

        frame = parent;

        setSize(700, 400);    //sets up panel
    }

    public void paintComponent(Graphics comp)                               //starts graphics, casts a Graphics 2D object
    {

        Graphics2D comp2D = (Graphics2D) comp;

        comp2D.setColor(Color.black);                                       //draws the framework for the graph
        comp2D.fillRect(0, 0, 700, 200);
        comp2D.setColor(Color.white);
        comp2D.drawString("Specific", 10, 70);
        comp2D.drawString("Gravity", 10, 85);
        comp2D.drawString("Time", 240, 195);
        comp2D.drawLine(70, 180, 690, 180);                                 //horizontal line = 620 pixels
        comp2D.drawLine(70, 180, 70, 10);                                   //vertical line = 170 pixels but work with 
                                                                            //180 because range is 1.0 to 1.090

        counting = frame.graphxvec.size();                                  // = total number of values in graphxvec vector

        int xold = 0;                                                       //to draw the lines from one point to the next
        int yold = 0;

        for (int i = 0; i < counting; i++)                                  //convert those values into doubles
        {
            double tempone =
                Double.parseDouble((String) frame.graphxvec.elementAt(i));
            double temptwo =
                Double.parseDouble((String) frame.graphyvec.elementAt(i));
            int    xcoord;                                                  //convert those doubles into integers
            int    ycoord;

            xcoord = (int) tempone;
            ycoord = (int) temptwo;

            if (i == 0)                                                     //for the first point, don't draw a line, set  
            {                                                               //xold and yold to equal the coordinates
                xold = xcoord;                                              //of the first point
                yold = ycoord;
            }

            comp2D.fillOval(xcoord, ycoord, 10, 10);                        //draw a dot
            comp2D.drawLine(xcoord, ycoord, xold, yold);                    //and a line from dot 2 to dot 1; 3 to 2; etc

            xold = xcoord;
            yold = ycoord;
        }
    }
}

class ExitWindow extends WindowAdapter {                                    //and, finally, another helper class--so the
                                                                            //the previous one wasn't the last one--sue 
    public void windowClosing(WindowEvent e) {                              //me.  <G>  To close the window.
        System.exit(0);
    }
}

//  Finit.


/*--- Formatted in Sun Java Convention Style on Mon, Feb 5, '01 ---*/


/*------ Formatted by Jindent 3.23 Gold 1.02 --- http://www.jindent.de ------*/
