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..
desiboy1974Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
JList does not have aremoveAll() method, what are calling removeAll() on exactly.
Sounds like you are not firing the appropriate event after removing
0
objectsCommented:
if use DLM then use model.clear();
0
desiboy1974Author Commented:
oh..i'm actually calling removeall() to clear and repopulate the items when the button is hit..so i need to use a datamodel?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

objectsCommented:
yes you need to remove the items from the model
another option would be to create a new model using setModel() or setListData()
0
desiboy1974Author Commented:
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.getString(1));
        }
 }      
       
0
objectsCommented:
that should work, check you are dealing with the correct list/model.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
desiboy1974Author Commented:
works fine thanks..
0
objectsCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.