How to clear a JList with Netbeans 6.5.1

Discussion in 'Software' started by Janc, Apr 26, 2009.

  1. Janc

    Janc

    Joined:
    Apr 26, 2009
    Messages:
    1
    Hi friends!

    Gareth, I hope you are still around here :oops:

    I'm quite new to java and Netbeans, so please, be patient :barresed:

    I have follow your recomendations here quoted, and it works fine first time I push the boton, but when I run it a second time, I get an error:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JList$4 cannot be cast to javax.swing.DefaultListModel

    I have a boton that start a files search function, and I wont to show results in a Jlist close to it, but I need to clear the Jlist every time a search for new files.

    I had tried every posibility I know, but it do not work.

    I put in:
    Generate Post Initialisation Code
    Lista.setModel(new DefaultListModel());

    Parts of my code are:

    private void BotonActionPerformed(java.awt.event.ActionEvent evt) {

    ...Searching for files...​
    ...I got files in a ArrayList<String>...​

    // Here is were is seems to have problems.​
    DefaultListModel model = (DefaultListModel) Lista.getModel();​

    model.clear();​

    Lista.setListData(ArrayList<String>...);​

    {

     
    Janc, Apr 26, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bhanu_pa

    proxy settings to download plugins for netbeans

    bhanu_pa, May 2, 2008, in forum: General Computer Support
    Replies:
    0
    Views:
    1,976
    bhanu_pa
    May 2, 2008
  2. nitesh sood

    problems with JList

    nitesh sood, May 22, 2008, in forum: Software
    Replies:
    0
    Views:
    758
    nitesh sood
    May 22, 2008
  3. Dee

    NetBeans servlets

    Dee, Jan 15, 2009, in forum: General Computer Support
    Replies:
    0
    Views:
    1,079
  4. kendarak
    Replies:
    0
    Views:
    1,149
    kendarak
    Jul 12, 2009
  5. frankyboy

    javalogo.jar in Netbeans

    frankyboy, Apr 10, 2010, in forum: Case Modding
    Replies:
    0
    Views:
    3,001
    frankyboy
    Apr 10, 2010
Loading...

Share This Page