I have created a Jlist which displays 1 colomn from a Database. I have stored all the elements in a Vector (Vector Valuelist) and then I did a SetListData. veldenList.setListData(valueList) ; Now I want to add new elements to the Jlist using the ActionEventHandler : private void fielddAdd(java.awt.event.ActionEvent evt) { // Add your handling code here: How do I accomplish this ? I've read that I should use a DefaultListModel but in my case I have used Vectors and a SetListData.... Anybody ? Thanks, Kristof
Hi, ucan't directly add or remove an element from a JList, instead use the DefaultListModel class. DefaultListModel dlm=new DefaultListModel(); JList jlst=new JList(dlm); Now to add an element to the list: dlm.addElement(element); & dlm.removeElement(element); to remove an element. Any changes to this model is reflected automatically in the JList. Happy middling with java. Netharam
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss