In my document model, I have created a vector of data objects. The vector
is then filled, and I printed output to ensure this.
When my update method is done, in the instance of the class myView, the
document model is passed to the update parameter (BlackBookDoc), but for
some reason the Vector is empty! I tested this with:
if((((BlackBookDoc)abs).getRDVector()).isEmpty()) result="EMPTY!";
else result=("RDVector has " + (((BlackBookDoc)abs).getRDVector()).size() +
"elements");
(this places "EMPTY!" in result)
here is the update method:
public void update(Observable abs, Object obj)
{
String result;
result =
(((BlackBookDoc)abs).getRDVector()).elementAt(0).toString();
text.setText(result);
}
note: text is a textArea
The error I get is:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at java.util.Vector.get(Vector.java:691)
at BlackBookView.update(BlackBookView.java:21)
at java.util.Observable.notifyObservers(Observable.java:146)
at java.util.Observable.notifyObservers(Observable.java:102)
at BlackBookDoc.<init>(BlackBookDoc.java, Compiled Code)
at MainBB.init(MainBB.java:24)
at MainBB.main(MainBB.java:15)
Exception in thread "main" Process Exit...
I also tried to test it with this:
result = ((BlackBookDoc)abs).toString();
and the result was:
BlackBookDoc@405e39fb (I assume a mem location)
Why is my vector empty?!?!?!?
HHHEEEELLLLPPP!!!!!! (please!)