Hi I am new to Swing & Java. I would like to display the content of a List. I used java.util.* components to create this list. Ex: List l = new ArrayList(); Now I would like to display the content of the List l through the GUI. I was trying to use JList, but JList constructor allows only Vectors. I am wondering how to display the contents of my List using Swing compenents. Since I am new to Swing & Java, I find it difficult. Please do let me know if you have any suggestions! Thanks in advance for all your help. Regards Kelly
There is a JList constructor that takes an Object as well. Pass your ArrayList into the constructor using the toArray(). The toArray() creates an Object from the contents. Make sure your toString() on the Objects within the ArrayList display what you want. That is the simplest method. Creating your own ListModel is another option.