?
Solved

list issue

Posted on 2005-02-24
8
Medium Priority
?
243 Views
Last Modified: 2010-03-31
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..
0
Comment
Question by:desiboy1974
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13398131
JList does not have aremoveAll() method, what are calling removeAll() on exactly.
Sounds like you are not firing the appropriate event after removing
0
 
LVL 92

Expert Comment

by:objects
ID: 13398138
if use DLM then use model.clear();
0
 

Author Comment

by:desiboy1974
ID: 13398156
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 92

Expert Comment

by:objects
ID: 13398179
yes you need to remove the items from the model
another option would be to create a new model using setModel() or setListData()
0
 

Author Comment

by:desiboy1974
ID: 13398332
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
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 13398383
that should work, check you are dealing with the correct list/model.
0
 

Author Comment

by:desiboy1974
ID: 13398515
works fine thanks..
0
 
LVL 92

Expert Comment

by:objects
ID: 13398725
:)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question