Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

list issue

Posted on 2005-02-24
8
Medium Priority
?
248 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

575 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