Hello friends..I am new to this forum .
I am developing small application using NetBeans 7.0 which has a JList on the form (from the palette) . I am filling the JList using the vector which contains records from database. But I can not clear the contents of the JList. Please help me friends. Here is my code
private void dateChooserSelectedDatePropertyChange(java.beans.PropertyChangeEvent evt) { DefaultListModel model = new DefaultListModel(); listSerialNo = new JList(model); UpdatePurchase updatePurchase = new UpdatePurchase(); Vector<String> serialNo = new Vector<String>(); serialNo = updatePurchase.getSerialNoForSelectedDate(date); if(serialNo.size()>0){ listSerialNo.setListData(serialNo); } else{ model.clear(); resetFields(); } }
If I use above code then neither Jlist contains any record nor it clears the contents of JList . If I remove
then atleast JList contains some records for specific date if available.DefaultListModel model = new DefaultListModel(); listSerialNo = new JList(model); // if & else code from above code snippet model.clear();
My aim is if there are records available for specific date then that record should be displayed in JList otherwise JList should be empty. Please guide me.
Thanks .