desiboy1974
asked on
list issue
hi,
i have 3 buttons and a target jlist....each button runs its oen query to populate the list..so if i hit button 1 its populates the list with its items..
i'm using list.removeAll(); to clear the list and repopulate but it doesnt seem to work..so when i press button 1, it still jkeeps the items from button2 etc..
i have 3 buttons and a target jlist....each button runs its oen query to populate the list..so if i hit button 1 its populates the list with its items..
i'm using list.removeAll(); to clear the list and repopulate but it doesnt seem to work..so when i press button 1, it still jkeeps the items from button2 etc..
if use DLM then use model.clear();
ASKER
oh..i'm actually calling removeall() to clear and repopulate the items when the button is hit..so i need to use a datamodel?
yes you need to remove the items from the model
another option would be to create a new model using setModel() or setListData()
another option would be to create a new model using setModel() or setListData()
ASKER
this is what i've done..but it still doesnt clear the data
DefaultListModel modelList1 = new DefaultListModel();
final JList list1 = new JList(modelList1);
----
-- get data from database
--
ResultSet rs = pstmt.executeQuery();
modelList1.clear();
while (rs.next()) {
modelList1.add(0,rs.getStr ing(1));
}
}
DefaultListModel modelList1 = new DefaultListModel();
final JList list1 = new JList(modelList1);
----
-- get data from database
--
ResultSet rs = pstmt.executeQuery();
modelList1.clear();
while (rs.next()) {
modelList1.add(0,rs.getStr
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
works fine thanks..
:)
Sounds like you are not firing the appropriate event after removing