Campbell Ritchie wrote:Why are you using Vector, rather than one of the more modern implementations of List? Is it that it is required by one of the Components? I know there are things like Combo-boxes which still require Vector.
You are trying to gain access to the second (=index 1) member of a 1-member array or list.
Or: to put it another way: You have one element in the Vector and you are trying to access its second element.
Remember the first member of a List or array is no 0.
pete stein wrote:In your code:
You're getting components by using getComponents() and then using an array index to get the components. This is a very fragile way of getting a reference to an object. Why not use the variable that you already have in your class? As it is, it is likely that components[1] doesn't exist ([0] is probably the contentPane).
Dss Ss wrote:
Which variable do you mean...?
Also, I'm not intentionally using vectors, where does that come?
The JFrame holds only one Component, the contentPane
luck, db
There are no new questions, but there may be new answers.
The JFrame holds only one Component, the contentPane, so in the components array it is held in position [0]. You're trying to get componets[1] which simply doesn't exist. But even if it did, this is not a good way to get your data. Rather your data should be accessible via a class getter method.
I presume Pete Stein's explanation in the post previous to that is correct; there is a Component which hides a Vector in its implementation somewhere, rather than a more efficient and modern implementation (eg ArrayList).Tom Huddersfield wrote: . . .
Also, I'm not intentionally using vectors, where does that come?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions