How to add element to existing JList

Well you can not use directly that Array but use this this will might help you for the same.

 DefaultListModel demoList = new DefaultListModel();
 demoList.addElement("addElements");
 JList listd = new JList(demoList);

That way you can add elemets into the LIST.


Populate the JList with a DefaultListModel, not a vector, and have the model visible in the class. Then simply call addElement on the list model to add items to it.

Tags:

Java

Swing

Jlist