How do I clear a JList?

Hello,
I would like to know how do I clear a Jlist of all it's content when I click on a button "Clear". I have all the codes working, except, I don't know what is the code line to do this...
I have found this: list.setModel(new DefaultListModel());
but it doesn't work...unless there is another problem with my codes?
Anyone can tell me what is the code the Clear the JList?
Thanks
Sylvie

All of these will work. I think I ran accross the JComboBox class which didn't have so many convenience methods, so I used the setModel(new DefaultComboBoxModel()) to clear out my combobox with a single line.
void setListData(Object[] listData)
Constructs a ListModel from an array of objects and then applies setModel to it.
void setListData(Vector listData)
Constructs a ListModel from a Vector and then applies setModel to it.
void setModel(ListModel model)
Sets the model that represents the contents or "value" of the list and clears the list selection after notifying PropertyChangeListeners.

Similar Messages

  • How to clear a  JList correctly.

    Hello,
    I haven't found yet how to clear a JList whitout raising an exception.
    I have defined a JList, that I initialize with a Vector. For example :
       JList mylist = new JList();
       Vector v =  new Vector(5);
       for (init i = 0; i<5; i++ )  v.add("Line " + i);
       mylist.setListData(v);
          .When the user needs to erase all lines, he has to click on a JButton. In the actionPerformed method, I'm doing the following
       Vector v = new  Vector();
       mylist.setListData(v);It works, but I got an ArrayOutBoundException. I tried many other things such as
    v.clear();
    mylist.setListData(v);
    but I got the same exception. So I was obliged to embed my instructions in a
    try-catch block:
       try
            Vector v = new  Vector();
            mylist.setListData(v);
      catch (Exception ex){}In fact , I do not like what I did , and I'm pretty sure it exists a much better way .
    Thanks in advance for any suggestion
    Gege

    This link has answer...
    http://forum.java.sun.com/thread.jspa?threadID=718897&messageID=4149627

  • How can i clear all events in ical

    how can i clear all events in ical

    Try typing "." without the exclamation points in the iCal search window. Then simply highlight all the entries > Edit/Delete

  • How do I clear a list of usernames which is automatically offered when I login to a site.

    For example, if I want to sign into gmail, it asks for the username. As soon as I type in the first letter, it gives me a selection which it stored. Once I made a mistake and typed my password in there which also begins with the same letter. How do I clear the list? Actually, how can I set Firefox so that it doesn't automatically store that information.

    Password Manager deals only with passwords. The problem described above is about the User Name. I tried the Shift+Delete tactic, and it worked! Be sure to follow instructions in the link provided in the solution: http://kb.mozillazine.org/Deleting_autocomplete_entries

  • How do we clear the GR/IR Reconciliation Report on PO

    Hi expets,
    can you please help me to solve this issue
    "How do we clear the GR/IR Reconciliation Report on PO"
    thanks in advance,
    mohammad

    > "How do we clear the GR/IR Reconciliation Report on PO"
    Use MR11 Trxn Code GR/IR Clearance

  • GR/IR Key manditory in PO...How can i clear customs duty befor GR

    Hi All,
    As per the business requirement, i made GR based IR manditory in PO. Now for Import Pos, how can i clear the customs duty before doing GR.]
    Regards,
    Naidu.

    Hi
    Custom duty is a delivery cost. You can process the delivery cost before GR even with activation of "GR Based IV".
    Control due to "GR Based IV" is applicable for goods item invoice.
    warm regards
    sairam akundi

  • How do I clear cache and cookies on my ipad

    How do I clear cache and cookies on my ipad?  I was told to do this when I was trying to download ebooks to ibooks and kindle

    Settings/safari/clear history;clear cookies and data

  • How can i clear the usernames and passwords history from all login websites?

    how can i clear the usernames and passwords in the log in history of the websites? example when i want to login to my facebook i always type first letter of my e-mail and it comes with the passwords because before i put remember my password, and in other websites so, i just need to delete all this login history and it's not working from the clear everything !!! :S any idea please !! thanks in advance :)

    See:
    http://kb.mozillazine.org/Deleting_autocomplete_entries
    http://kb.mozillazine.org/Password_Manager

  • I have forgotten my password and locked my phone, how can i clear the problem

    I have forgotten my password and locked my phone, how can i clear the problem

    By coincidence, this happened to my son just last night.  You do NOT have to restore it to a new phone, but you probably want a current backup.
    Luckily, you can still sync and back it up even if it's locked, so connect it to the computer you usually sync it to. Go to the summary page. It's easiest and fastest to use a local backup, so if iCloud backup is on, turn it off and click "Backup now".  
    After it backs up, either click "Restore iPhone", or
    - hold home and the top button until the screen goes black, release the top and continue to hold the home button until iTunes says "iPhone in recovery mode detected". 
    Follow instructions to restore from backup, and then sync to restore content.  Your phone will come up in an unlocked state. If you have any stuff that was purchased directly to the iPhone (only), you'll have to re-download it. 
    Remember to turn iCloud backups back on if you use them.
    If you don't sync you iPhone to a computer then I *think* those instructions with the buttons will put it into a mode where you can restore it from the cloud (make sure it is NOT connected to a computer while you do this). Otherwise, you will have to restore it as a new phone, then go to settings, reset, then restore it from the cloud.

  • TS3297 iTunes puts up a message "The item you've requested is not currently available in the Hong Kong Store." I had not requested anything from the HK store at that point, and I have never used any store other than the HK one. How I can clear that messag

    I've been running iTunes on WinXP for years with few problems.  I have all my iTunes files on an external USB drive. I just bought a new PC running Win7, 64-bit.
    I connected the external USB drive to the new PC and installed 64-bit iTunes on it. When iTunes started up, I pointed it at the iTunes directory in the external drive, using Edit > Preferences > Advanced > iTunes Media Folder Location. It showed a progress bar that it was updating the iTunes Library. I signed in and authorized the new machine. I have one spare authorization.
    Then iTunes put up a message "The item you've requested is not currently available in the Hong Kong Store." I had not requested anything from the HK store at that point, and I have never used any store other than the HK one.
    When I click OK, the iTunes Store page remains blank, apart from saying "iTunes Store" in the middle of the page.
    I went to "View My Account" and pressed the Reset button to "Reset all warnings for buying and downloading items", but that doesn’t fix this particular warning. I also tried Edit > Preferences > Advanced > Reset Warnings and Rest Cache.
    But still, every time I click the “App Store” button in the iTunes Store window, the message appears. If I click the Books, Podcasts or iTunesU buttons, these display normally.  So I’m stuck with being unable to purchase apps, other than through my iPad and iPhone.
    If I move the external drive back to the XP machine, the same thing happens.  If I go to another PC - a notebook running Vista - everything is normal.
    Any idea how I can clear that message?
    Thanks for any help you can offer.

    Further info on my question above.
    I have tried re-validating my credit card, which apparently fixed it for some. 
    I have also tried uninstalling, re-downloading and installing again.
    Neither of these steps fixed the problem.

  • How do I clear the downloads folder?

    How do I clear the downloads folder?  I swear there used to be an option for this when I right clicked on the downloads folder that is on my bottom bar but I don't see one now.  This is making me crazy.
    Also, when I click on the bottom bar Downloads folder to display the items in the Downloads folder, I've selected it to be arranged as a fan and by the date added.  I've downloaded two copies of the same item and did this back to back because I didn't see the first download in the folder once I'd downloaded it.  I don't see the first of the two downloads unless I open the whole folder in its own window.  Shouldn't I see them both at the bottom of the list since they are the two most recent downloads?  I'd accidentally downloaded duplicate copies previously and it had displayed them in this manner.
    Please help!

    The best way to delete is just open them in finder.  Mark them all and delete.
    In the fan, you can select the sort order by right click (cntl click) the download folder and choosing "sort by" date added.
    Regards,
    Captfred

  • How do I clear files in data & usage

    How do I clear files in data &amp; usage, or is it important and has is not to be removed

    I don't beleive you can. It's attached to the app the app that requires it. If you're looking to clear space, you can look for individual files to delete within the app, such as podcasts within the podcast app. Or you would have to delete the app entirely.

  • I bought the iPad and got it home and when I turned it on, all I see is the iTunes logo w/ a usb connector and arrow. How do I clear that and go to the home screen??? HELP!

    i bought the iPad and got it home and when I turned it on, all I see is the iTunes logo w/ a usb connector and arrow. How do I clear that and go to the home screen??? HELP!

    You need to Set Up the iPad... Connect it to iTunes...
    See here for Getting Started...
    http://www.apple.com/support/ipad/
    and here...
    iPad User Guide iOS 5
    http://manuals.info.apple.com/en_US/ipad_user_guide.pdf

  • How can I "clear" my old IPad? I'll sell it and must restart it from the begining as new, create new Apple ID,etc?

    How can I "clear" my old IPad ? I'll sell it and must restart it from the begining as a new one. To leve it as when I had purchased it.

    Settings>General>Reset>Erase All Content and Settings

  • I entered the incorrect password for my home wifi network and now I can't change it. How do I clear out the wrong password so that I can enter a correct one?

    I entered the incorrect password for my home wifi network, and now I can't change it. How do I clear out the wrong password so that I can enter a correct one?

    Settings > wi-fi  then tap on the little blue arrow next to the network you want to change. You have to tap on the blue arrow and not on the name.
    Now at the top tap on "forget this network".
    After that, the iPhone will think your home network is a new network and will ask you for the password to connect.

Maybe you are looking for

  • Lightroom 5.4. Edit options are greyed out. I tried reset warnings already.

    Hi, I just added a bigger harddrive and reinstalled Lightroom 5.4. Now,  2 of 3 edit options are greyed out. No access to plug-ins or external editors for original files.(NEF's) I tried reset warnings already.

  • Use sumif() with Excel 2010 sheets stored on SharePoint 2010

    Hello everyone, I am experiencing an issue with two Excel sheets stored on SharePoint 2010 in a simple document library within a team site. One of the files contains the source data (data.xlsx) and the second file contains the formulas calculating di

  • Flex Builder 3 error  JVM terminated, Exist code=13

    When i try to open flex builder 3, this message pops up suddenly and i don't know how to solve. Please help me.

  • InDesign on MacBook Air or on 2 GB RAM on laptop?

    Having broken my shoulder, I am no longer able to carry half the weight I once could. So even my tiny MacBook Pro 13 is too much for me. Anyone have experience running ID as well as PSD, Flash, AI, Acrobat, and some other CS5 programs on a MacBook Ai

  • Need ur opinions...

    hi everybody.... m a student currently enrolled in 4 yr bachelors degree in computer systems... during my internship i had an opportunity to work on oracel EBS. i want to continue my learnings in this field... according to degree requirements we have