Brandon McCombs said:
I have one last line that I can't fix the warning for.
allAttribsAndVals.get(i).add( newField.getText() );
allAttribsAndVals is declared as Vector<Vector> and the Vectors that it
holds are declared as Vector<String>. No matter what I do I can't get the
warning to go away. Any ideas?
Well, you haven't specified the text of the warning you are getting for this
line so that makes it a little hard ;-)
Looking at the API for Vector, it seems that this version of the add()
method is expecting a value of type 'E' but I'm still rocky on the notation
so I'm not completely sure what 'E' means in this context. You haven't said
what type 'newField' is but I'm guessing that its a JTextField or JTextArea,
which means it is using the getText() method from JTextComponent, which
returns a String: that should work fine. But there are many other getText()
methods, some of which don't return Strings. Look up the API for the type of
'newField' then see what it's getText() method is returning; if it's not a
String, that is likely your problem. Ultimately, I think the add() method
will have to pass a String to the Vector otherwise you'll continue to the
get the warning.
If newField.getText() _is_ returning a String, I'm not sure what the problem
is. In that case, perhaps someone else with better understanding of Generics
can help you.
Or maybe you'd like to wade through the Generics tutorial yourself so that
you can figure it out on your own? The main Generics tutorial is at
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf but parts of it are
over my head since my theory isn't that strong. I think there's a more basic
tutorial as well but I don't remember where I saw it.