> Wondering how you add an ArrayList's data into a
> JList?
I've not tried but the API's suggest that:
JList delList = new JList(myArrayList.toArray());
should work.
http://java.sun.com/javase/6/docs/api/javax/swing/JList.html#JList(java.lang.Object[])
http://java.sun.com/javase/6/docs/api/java/util/ArrayList.html#toArray()
> > Wondering how you add an ArrayList's data into a
> > JList?
>
> I've not tried but the API's suggest that:
> [code]
> JList delList = new
> JList(myArrayList.toArray());
> /code]
> should work.
>
> http://java.sun.com/javase/6/docs/api/javax/swing/JLis
> t.html#JList(java.lang.Object[])
> http://java.sun.com/javase/6/docs/api/java/util/ArrayL
> ist.html#toArray()
That will work just fine.
@OP: Keep in mind that if your ArrayList contains objects which do not have an overridden toString() method, you may not get your desired results.
> Thanks! That worked just fine!
>
> BTW, I now get "malformed floating point literal"
> error. Any idea what that is?
Are you trying to display some type of floating point data? Is the error occuring when the JList is trying to display its contents?
If so, as Navy_Coder suggests you may need to override the "toString()" method of the object that is being displayed in the JList.
If this is not it, where in your code are you seeing this error?