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

Similar Messages

  • How to clear a JList ?

    Hello,
    I have the following code.
        JList  jl = new JList();
         Vector v = new Vector(5000);
                        then I fill the vector with Strings loaded  from a MYSQL table
          jl.setListData(v);
      Later I refill entirely the vector with other values. If I issue again
               jl.setListData(v);
      I got a ArrayIndexOutOfBoundsException exception. I don't understand why
    anyway, How can I just clear all lines in my JList, before to fill it again.
    Thanks a lot in advance
    Gege

    >
    anyway, How can I just clear all lines in my JList,
    , before to fill it again.
    Thanks a lot in advance
    Gegehi,
    you might need to declare your list like this
    DefaultListModel listModel = new DefaultListModel();
    JList list = new JList(listModel);then to clear the list at any stage
    listModel.clear();i have recently used this code to list user names in a chat room.
    so it should do the job for you!
    cheers
    RC

  • 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.

  • I can't update IPhoto, it says "the product distribution file could not be verified it must be damaged or signed in" I bought it on iTunes and have 8,000 photos already. how can I update and correct this??

    I can't update IPhoto, it says "the product distribution file could not be verified it must be damaged or signed in" I bought it on iTunes and have 8,000 photos already. how can I update and correct this??

    You might try resetting the App Store application and clear the cookies via this menu:
    as described in this website: Make use of the Mac App Store debug menu | MacFixIt - CNET Reviews
    OT

  • How to clear the field in APEX...?

    Can any body tell me how to clear or reset the fields in the user interface (APEX 4.0)...? i.e., page items... when i click reset button i want all the fields in my region to be cleared...
    thanks,
    - regards,
    Beginner...

    Create a new process, select "Session State" as process category. Select "Clear Cache for all Items on Pages (PageID,PageID,PageID)" as Process Type.
    Set the conditions to bind it to your button.
    Best Regards,
    Gokhan Atil
    If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks

  • How to clear the hung calls in CUBE?

    I'm installing a new CUBE as SIP-SIP gateway in Cisco 2921, IOS: 15.1(4)M3. When i tried few test calls, I saw couple of hung calls in it.
    I tried clearing them manually with the below command but it didn't help.
    clear call voice causecode identifier{id identifier | media-inactive | calling-number number | called-number number}
    >> https://supportforums.cisco.com/docs/DOC-34379
    The call legs are still in connecting status.
    2    : 2152 13:36:28.319 CET Tue Feb 11 2014.1 +-1 pid:200 Answer 222022029 connecting
    dur 00:00:00 tx:0/0 rx:0/0
    IP X.X.X.97:24578 SRTP: off rtt:0ms pl:0/0ms lost:0/0/0 delay:0/0/0ms g711ulaw TextRelay: off
    media inactive detected:n media contrl rcvd:n/a timestamp:n/a
    long duration call detected:n long duration call duration:n/a timestamp:n/a
    2    : 2157 13:38:54.589 CET Tue Feb 11 2014.1 +-1 pid:200 Answer 222022029 connecting
    dur 00:00:00 tx:0/0 rx:0/0
    IP X.X.X.97:24582 SRTP: off rtt:0ms pl:0/0ms lost:0/0/0 delay:0/0/0ms g711ulaw TextRelay: off
    media inactive detected:n media contrl rcvd:n/a timestamp:n/a
    long duration call detected:n long duration call duration:n/a timestamp:n/a
    Also, I tried enabling media inactivity timer but it would clear only the calls in 'Connected' status If I understand correctly.
    how to clear those hung calls? and what could be the cause of it?
    Any help would be much appreciated.
    Thanks in advance
    Suresh

    Suresh have you tried this:
    ip rtcp report interval 5000
    gateway
    timer media-inactive 5
    The challenge you may face is that the media inactivity was not configured before this call started, hence it cant activate the time for this particular call...
    Give it a go, lets know if it works. Even if it doesnt I suggest you enable this on your CUBE going forward, so you dont haver hung calls in the future
    example: You can use the debug ccsip events to see the media inactivity timer kicking in for a call...
    Router# debug ccsip events
    00:04:29: sipSPICreateAndStartRtpTimer: Valid RTP/RTCP session found and CLI ena
    bled to create and start the inactivity timer
    00:04:29: sipSPICreateAndStartRtpTimer:Media Inactivity timer created for call.
    Mfactor(from CLI): 5 RTCP bandwidth: 500
    RTCP Interval(in ms): 5000
    Normalized RTCP interval (in ms):25000
    Please rate all useful posts
    "The essence of christianity is not the enthronement but the obliteration of self --William Barclay"

  • How to clear the input values in WD4A

    Hi all,
    Thanks in Advance.
    In my login page i have ID and Password.If Login fails it back to the same login page.But at the same time the entered(In ID and Password)will be cleared.If i write the code in inboundhandler is it correct means how can i write to invalidate the input values???Is there any examples or related links???

    Hi,
    Please have a look at this similar thread:
    how to clear entered values.
    Hope this helps!
    Regards,
    Srilatha

  • How to clear the contents of table control

    Hi All,
              How to clear the contents that are present in a Table control. If there is any code Please Let me know.
    I will assign full marks to the correct code.
    Pradeep Kumar Kota.

    Hi
    U need to clear the contenents of internal table used to store the record displayed by table control.
    Every time the PBO is triggered the table control is automatically cleared, so you need only not to transfer any data from internal table to table control.
    So you should show how your PBO if you want a right answer.
    Max

  • How to clear the cache files in folder Temporary Internet Files

    When one user opens files such as pdf. or doc. from Portal,  the same file will be downloaded into the Temporary Internet Files folder. if another user copied the files out of the Temporary Internet Files folder from this computer and save to someplace else, then we face one security problem.
    So my question is: How to clear the cache files in folder Temporary Internet Files??  Can we delete the files automatically when close the files in Portal??
    or is there some ways to make encrypty???
    Thanks very much!

    Hello,
    this is a basical security problem which should be resolved by the OS standard security setup . No other user should have access to the temporary file folders in the personal directory. The user account must be secure. Normaly your security problem should not be a problem if basic security exists on the clients.
    You can resolve this problem if every user has his own account on the client
    The users having no administration permissions on the clients
    The folder for the temporary internet files is placed in the personal profile folder of the user account.
    On default no other user has access rights to you personal folder, this means the client OS is setup correctly.
    You can setup the IE that no temporary files are saved (but it reduces performance)
    You can enable IE to delete automaticly the temporary files if IE is closed.
    Hope it helps.
    Regards
    Alex

  • TS4006 My iphone & ipad mini are both here w/ me at my home. But the findme app is showing my ipad mini on the other side of town, how can i get that corrected?

    My iphone &amp; ipad mini are both here w/ me at my home. But the findme app is showing my ipad mini on the other side of town, how can i get that corrected?

    Hello Krazyboutgolf,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    iOS 7: Understanding Location Services
    http://support.apple.com/kb/HT5594
    Improving GPS accuracy2,4
    GPS accuracy varies depending on the number of visible GPS satellites. Locating all visible satellites can take several minutes, with accuracy gradually increasing over time. Use these tips to improve GPS accuracy:
    Ensure the date, time, and time zone are correctly set on the device in Settings > General > Date & Time. If possible, use Set Automatically.
    Important: Incorrect settings on your computer can sync to your device. Verify the date, time, and time zone on any computer that syncs with your device.
    Restart your device.
    Verify that you have a cellular or Wi-Fi network connection. This allows the Assisted GPS (A-GPS) on the device to locate visible GPS satellites faster, in addition to providing initial location information using the Wi-Fi or cellular networks.
    Note: Microcells (sometimes called Femtocells) aren't supported with Location Services.
    Maintain a clear view of the horizon in several directions. Keep in mind that walls, vehicle roofs, tall buildings, mountains, and other obstructions can block line of sight to GPS satellites. When this occurs, your device will automatically use Wi-Fi or cellular networks to determine your position until the GPS satellites are visible again.
    Best of luck,
    Mario

  • Hi, can you help?  My emails that I have received show the date received as either today, yesterday or July 28.  How can I get the correct date received?

    Hi, The emails that I have received show the date received as either today, yesterday or July 28.  How can I get the correct date received?

    That's very scary. They might do it, but I personally have never had Apple contact me re id's except on their site when signing in. I suggest you DO NOT respond until you have a phone conversation with Apple security. They can verify if they sent you the e-mail and why.
    While it's very possible it's true,again, I suggest you not respond until you speak to someone at Apple. I've often read here that when people sign in they are not allowed to because "someone else has used the id" type of statement.
    Also, you should be able to go to the app store and see what apps you have downloaded.
    Though it could have been a free app, have you checked to see if any were bought with your id account?
    I've gotten these types of e-mails from places like USPS and FedEx which look amazingly authentic and were from their website. I also received an odd e-mail from my cousin in Ireland last year that clearly was not from him. It was also sent to others in his family in Ireland. I e-mailed him that I only opened it because it had a .ie, but suggested he change... Days later I received mail from 'him' - same name, but at yahoo.com. 
    Again, I would call Apple. You can also report it at [email protected], but I would not settle for that given your situation. If nothing else, call Apple sales (sales depts. anywhere answer fast) and ask them to transfer you to security. Apple will not want anybody accessing their name, and while it's unlikely, it's not impossible that it is someone phishing.
    Hope this helps and can you let the support community know your results by posting on this thread when you're done? Thank you.
    Hope this helps.

  • How to clear completed reminders in iCal

    Has anyone figured out how to clear completed (checked done) reminders in iCal?

    Joe,
    That clarifies the question for me. Go to iCal>Preferences>Advanced and make your choices:

  • How to clear text fields when the user navigates back to the screen

    Hi,
    Does anyone have any idea on how to clear the text input fields and dropdown boxes when the user navigates back to the screen, say for e.g. create screen?
    My issue is that i have plenty of fields in the create screen within a form. Is there a way to avoid programaticaly blanking out every field and just do it at the form level using an api to reset to a state before the user entry?
    Thanks

    This code allows you to make it more generic, and you would need to tweak it if there are more than TextInput controls, but it should provide some ideas.
    As far as using states, you could use SetProperty to set the text to empty, but that might be messier.
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.containers.FormItem;
          import mx.controls.TextInput;
          import mx.events.IndexChangedEvent;
          import mx.core.Container;
          private function clearSreen(evt:IndexChangedEvent):void{
            var view:Container = tn.selectedChild as Container;
            for each(var child:Object in view.getChildren()){
              if(child is FormItem){
                var subchild:DisplayObject = child.getChildAt(0);
                if(subchild is TextInput){
                  TextInput(subchild).text = "";
        ]]>
      </mx:Script>
      <mx:TabNavigator id="tn" resizeToContent="true"
        change="clearSreen(event)">
        <mx:Form id="frm1" label="View Number One">
          <mx:FormItem label="First name:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="Last name:">
            <mx:TextInput/>
          </mx:FormItem>
        </mx:Form>
        <mx:Form id="frm2" label="View Number Two">
          <mx:FormItem label="Address1:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="Address2:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="City:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="State:">
            <mx:TextInput/>
          </mx:FormItem>
          <mx:FormItem label="Zip code:">
            <mx:TextInput/>
          </mx:FormItem>
        </mx:Form>
      </mx:TabNavigator>
    </mx:Application>
    If this post answers your question or helps, please mark it as such. Thanks!
    http://www.stardustsystems.com
    Adobe Flex Development and Support Services

  • How to clear vendor open items with customer open items in APP?

    Hi Experts,
    Our vendor is our customer - in this scenario how to clear vedor open items against customer open items. I have defined vedor is customer means I have given customer number in vendor master record, selected chek box 'clear with customer'.  Still problem is not solved, hence I am requesting you to help me in this regard.
    Thank you very much,
    Regards,
    Ganesh.

    Hi
    In FBCJ after payment you have clear manually vendor balance in F-44.
    If you want SPL GL in FBCJ then write a Substitution .
    1. step 001 - Special G/L Substitution
    2. Prerequisite - Transaction code = 'FBCJ'
    3. Substitution posting key -- Exit (need help from abap) exit name
                                              G/L Exit (need help from abap) exit name
                                              Special G/L Ind Exit (need help from abap) exit name
    you can't do this without ABAP help
    Best Of Luck
    Tanmoy

  • How to clear vendor open items if vendor invoice currency and payment currency different

    Hi All.
    How to clear vendor open items through f-44 if vendor invoice currency is EUR , payment currency is USD  but local currency is INR
    while clearing through f-44 system showing error as "to large for clearing clearing is not possible"
    I checked all configuration, configuration wise no problem
    BR.
    Chandra

    Hi Chandra,
    You chose any one of the currency i.e. EUR/INR/USD for clearing in F-44. After selecting line items for clearing, system will show a difference. Click on over view button and manually write off the difference by selecting any one account i.e. dummy or small diff.account, after that click on process open items then system will show the difference 0 and simulate the document, here system will post gain/loss exchange GL postings along with other line items. After save the document, manually pass journal entry to dummy account and gain/loss account. I have explained clearly in the below example.
    Invoice is in USD - 1000 & INR - 60000
    Payment is in INR - 60000
    Now I am going to clear these in INR currency in F-44 on 31.03.2015. On this date the exchange rate for USD is 60.10. At the time of clearing system will post the below entry
    Vendor A/c Dr 60000 (invoice)
    Vendor A/c Cr 60000 (Payment)
    Gain from exchange rate A/c Cr  100 (60000 - 60100)
    Small diff.write off A/c (or) Dummy A/c Dr 100
    After done the above posting, we have to pass below manual JV in FB01
    Gain from exchange rate A/c Dr  100
    Small diff.write off A/c (or) Dummy A/c Cr 100
    Regards,
    Mukthar

Maybe you are looking for

  • How Do I tell if Netscape or Explorer was used?!

    Hi, here is the problem, I have an application in which I need to know wether it is being accessed by Netscape Navigator or Internet Explorer. This is so I can put a desktop shortcut on the user's machine that has the prefix of that browser. I have t

  • File Set Up for CD Auto Play on Mac

    I have a small website that I need to burn to a CD and AutoPlay when inserted into a drive. I have set up a couple "AutoRun"executable files (for those PCs out there) which works fine, but the CD will not AutoPlay on a Mac. The HTML files (on the CD)

  • Loading XML File into Oracle 10G XE

    I am trying to load an XML file into 10G XE from the Utilities interface, I have created a Table to load into but when I try to load I get the following cryptic error "XML Load Error". There is no other information, can someone give me some insight w

  • Can i connect apple ids to cretae a family pack

    Is there a way to connect different apple-id:s to create a family bundle. Instead of buying 4 full price apps i can buy it on two devices and install them on the other two. I want also to be able to use find friends (family) etc.

  • Account assignment with fi

    Dear All Happy new year. i have a doubt, please focus on some light on this one.  what is the main link between fi and mm regarding Account Assignment.  When ever enter into Purchase Order It shows WBS element is wrong or the Cost Center is Wrong.  W