Jlist.setListData()

Hi everyone!
I use a Jlist to display the contents of a vector,in which items are added and removed in run-time. I use the function:
myList.setListData(myVector);
but sometimes it works just fine, sometimes myList displays nothing and sometimes the list diaplays its old contents! I used myList.revalidate() before and after changing the list, i also revalidate the JScrollPane that the list is in, but occasionally this happens.
Does anybody had the same problem or knows how to fix this? Am i using the function setListData() correctly or do i need to do something else when altering the Vector?
I am new to java, so any help will be appreciated...

well, in many part of my code i use the same method. and it works well all the time.
I'm not quite sure to know how to explain your problem but maybe it is because you do something like:
JList jl = new JList();
jl.setListData(vector);
//removal
vector.removeElement(Object o);
jl.revalidate();
}when you should code:
JList jl = new JList(vector);
//removal
vector.removeElement(Object o);
jl.setListData(vector);
jl.revalidate();

Similar Messages

  • JList not showing elements

    Hi To all,
    I am trying to get elements in a JList.All the things are going right but in the application it is not showing any data.
    my code is like ...
    JList jlist=new JList();
    while(---code---)
    //some code
    Vector datalist = new Vector();
    String fname=f.getName();
    for(int i=0;(i<datalist.size());i++)
    datalist.add(fname);
    jlist.setListData(datalist);
    System.out.println(datalist);
    it is showing all names in dos prompt through System.out.println()..
    but not through jlist.
    Any help please
    Thanks in advance

    I'm having a problem with JList (it's not showing the
    elements added to the List).
    i've checked the forum, but couldn't found the answer
    to my problem. Any suggestion on the forum search
    keyword?
    here's my code
    public class TestClass extends JFrame{
    public static void main(String args[]){
    JFrame fra = new MyClass();
    fra.show();
    public class MyClass{
    private JList list;
    public MyClass(){
    setSize(400,300);  
    list = new JList();
    JSplitPane split = new
    ew JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
    new JScrollPane(tree),
    new JScrollPane(fileList));
    ContentPane c = getContentPane(c);
    c.add(split);
    } // end of constructor
    public populateListAtRunTime(){
    DefaultListModel listModel = new
    ew DefaultListModel();
    listModel.addElement("Testing 1");
    listModel.addElement("Testing 2");
    list = new JList(listModel);/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    With this line you are not changing the
    list you have already added to the SplitPane
    (I think it is already added before this gets
    called, you never show the relationship of this
    method to the constructor...), instead, you are
    creating a new JList which you never add to
    anywhere. Is there a way to instead add elements
    to the JList's data model instead of creating a new
    one? Something like this:
    DefaultTableModel listModel = list.getListModel(); //Or something like it...
    listModel.addElement(//...);
    list.revalidate();
    } // end of myClass (inner class)
    The tree showed up in the split pane
    And i think the list also showed up on the splitpane
    also (except that the element value is not
    there)...any clue on why this is happening?
    sorry again..i know this topic must have been posted
    numerous time, but i'm bad with search term
    keyword..and did not find any result that come close
    to my match
    I tried JList + visible, JList + show, and a few
    other

  • Help get rid of nagging JList UI exception

    Does anyone have an idea how to get rid of this nagging exception? By the way, my program continues to run just fine even when it's thrown. I suspect it's thrown because the JList UI is updated while the Listener event is fired...
    But I just cannot figure out a work-around for this.
    So, the culprit code snippet is:
    -----------start code-------------------
    oldlist.addListSelectionListener(new ListSelectionListener() {           
    public void valueChanged(ListSelectionEvent e) {
    if(e.getValueIsAdjusting()){
    Object selectedValue = oldlist.getSelectedValue();
    newlistdata.add(selectedValue);
    newlist.setListData(newlistdata);
    newlist.updateUI();
    //How to get rid of this nagging UI exception?
    oldlistdata.remove(selectedValue);
    oldlist.setListData(oldlistdata); // EXCEPTION THROWN HERE!
    oldlist.updateUI();
    ------------end code------------------
    And the stack trace is:
    Optimization completed successfully.
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1312)
    at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1292)
    at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(BasicListUI.java:2605)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)
    at javax.swing.DefaultListSelectionModel.removeSelectionIntervalImpl(DefaultListSelectionModel.java:559)
    at javax.swing.DefaultListSelectionModel.clearSelection(DefaultListSelectionModel.java:403)
    at javax.swing.JList.clearSelection(JList.java:2013)
    at javax.swing.JList.setModel(JList.java:1646)
    at javax.swing.JList.setListData(JList.java:1687)
    at panorama2flashtools.Main$1.valueChanged(Main.java:215)
    at javax.swing.JList.fireSelectionValueChanged(JList.java:1765)
    at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1779)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)
    at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)
    at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)
    at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442)
    at javax.swing.JList.setSelectionInterval(JList.java:2035)
    at javax.swing.plaf.basic.BasicListUI$Handler.adjustSelection(BasicListUI.java:2721)
    at javax.swing.plaf.basic.BasicListUI$Handler.mousePressed(BasicListUI.java:2677)
    at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:263)
    at java.awt.Component.processMouseEvent(Component.java:6035)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3983)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    BUILD SUCCESSFUL (total time: 35 seconds)
    Thanks!

    jaarik wrote:
    I suspect it's thrown because the JList UI is updated while the Listener event is fired...Quite likely. Are you executing that code in the event thread (the Swing thread) or in some other thread? If the latter, or if the answer is "Huh?" then read the Swing threading tutorial.
    And by the way, there's a Swing forum (scroll down a bit) which is inhabited by people who know Swing a lot better than I do.

  • JList(remove)

    Hi,
    I want add an remove strings from JList on run time. I have an array assigned to JList
    fileList.setListData(fileNames);
    Then I am getting the name of a node form tree
    Then compare it try to remove it. Seems like nothing happening
    TreePath currentSelection = tree.getSelectionPath();
    String tmp=currentSelection.toString();
    for(int i=0; i<=fileCount; i++)
    if(tmp==fileNames){
    fileNames[i]=null;
    while(i<fileCount){
    fileNames[i]=fileNames[i+1];
    i++;
    fileNames[fileCount]=null;
    fileCount--;
    Cold you tell me how can I correct this?

    Your code (plus my comments):
    TreePath currentSelection = tree.getSelectionPath();
    String tmp=currentSelection.toString();
    for(int i=0; i<=fileCount; i++)
        if(tmp==fileNames){
    fileNames[i]=null; //not needed, will be overwritten anyway
    while(i<fileCount){
    fileNames[i]=fileNames[i+1];
    i++;
    fileNames[fileCount]=null;
    fileCount--;
    OK, it makes a little more sense now.
    try doing jList.setListData(fileNames);

  • JList Help

    Can someone please help me with this...
    I want to do the following things in JList, what method should i use?
    1. remove a selected item
    2. add new itme into the list
    3. get the selected item
    4. get all item
    5. get the size of the list
    hope someone can help me with this..
    Thx

    Hi,
    if you are normally working with JList (it is different to java.awt.List).
    The best way for this will be:
    having a Vector with all you items in it. construct a JList with the constructor which has a vector as parameter.
    1. remove it from the vector and set the new vector to the jlist (setListData)
    2. add to vector (see above)
    3. getSelectedIndex()
    4.the items are in the vector
    5. the size is the size of the vector
    regards

  • [svn:osmf:] 10996: Changing MediaElementLayoutTarget to be constructed via a static ' getInstance' method, instead of by its constructor.

    Revision: 10996
    Author:   [email protected]
    Date:     2009-10-19 07:45:26 -0700 (Mon, 19 Oct 2009)
    Log Message:
    Changing MediaElementLayoutTarget to be constructed via a static 'getInstance' method, instead of by its constructor. This prevents the construction of multiple instances that reference one single media-element. Updating client code accordingly.
    Extending layout unit tests. Adding a custom renderer, checking calculation and layout passes invokation counts.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/osmf/composition/CompositeViewableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/composition/ParallelViewableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/composition/SerialViewableTrait.as
        osmf/trunk/framework/MediaFramework/org/osmf/gateways/RegionSprite.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/DefaultLayoutRenderer.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/LayoutContextSprite.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/LayoutRendererBase.as
        osmf/trunk/framework/MediaFramework/org/osmf/layout/MediaElementLayoutTarget.as
        osmf/trunk/framework/MediaFramework/org/osmf/utils/MediaFrameworkStrings.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/composition/TestParallelViewableTrai t.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/gateways/TestRegionSprite.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/layout/TestDefaultLayoutRenderer.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/layout/TestLayoutUtils.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/layout/TestMediaElementLayoutTarget. as
    Added Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/composition/CustomRenderer.as

    AlexCox, can you clarify that once you get the default model out and save it in the temp var, that your ONLY access to the data is then through temp and never through the JList methods?
    Quick question for everyone: Are any of you using JList.setListData to set you initial dataset? I think that is where the bug lies. When I do not use it and start with an empty list, I am able to add to that list, and then remove from that list using the following line:
    ((DefaultListModel)myList.getModel).remove(###);
    And this cast works everytime.
    But when I start that list out with some data such as:
    myList.setListData(myStringArray);
    and then try to execute the above line, boom! I get the ClassCast exception.
    I think setListData creates a whole new model which is an inner class to JList (which seems stupid when DefaultListModel seems made for this).
    Just my thoughts on where the problem lies. I'll add my data directly to the list and see if that works better.
    PK

  • A Simple Solution to the Slowness Problem

    Here is a simple solution that worked for me and will probably work for a lot of other people too. Hold down the ALT key when you open iPhoto. iPhoto then allows you open a new library or choose from your existing libraries. If you open a new library you can download images from your camera into the new library. Presto! You have a small number of photos to work with and iPhoto chugs merrily along with no slowness whatsoever. You want to go to another library? Simple: close iPhoto, then reopen it while holding down the ALT key again. Choose the library you want. I have hunted high and low for a solution to the slowness problem for months. This is far and away the best one I have found.
    If you have a lot of photos in your existing library, you will need to divide it up into smaller libraries. I suggest making a library for each month of photos. If iPhoto is still slow on a particular library, divide that library into smaller libraries. This is time consuming, but at least you only have to do it once. It is worth it to get iPhoto back.

    AlexCox, can you clarify that once you get the default model out and save it in the temp var, that your ONLY access to the data is then through temp and never through the JList methods?
    Quick question for everyone: Are any of you using JList.setListData to set you initial dataset? I think that is where the bug lies. When I do not use it and start with an empty list, I am able to add to that list, and then remove from that list using the following line:
    ((DefaultListModel)myList.getModel).remove(###);
    And this cast works everytime.
    But when I start that list out with some data such as:
    myList.setListData(myStringArray);
    and then try to execute the above line, boom! I get the ClassCast exception.
    I think setListData creates a whole new model which is an inner class to JList (which seems stupid when DefaultListModel seems made for this).
    Just my thoughts on where the problem lies. I'll add my data directly to the list and see if that works better.
    PK

  • How t print out selected values from a Jlist

    hi iam trying to get the selected values from a list to print out as a string but iam getting ,Invalid cast from java.lang.Object[] to java.lang.String.is there any way to get the selected values t print ut as a string?? import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MultipleSelection2 extends JFrame {
    private JList colorList, copyList;
    private JButton copy;
    private String colorNames[] =
    { "Black", "Blue", "Cyan", "Dark Gray", "Gray",
    "Green", "Light Gray", "Magenta", "Orange", "Pink",
    "Red", "White", "Yellow" };
    public MultipleSelection2()
    super( "Multiple Selection Lists" );
    Container c = getContentPane();
    c.setLayout( new FlowLayout() );
    colorList = new JList( colorNames );
    colorList.setVisibleRowCount( 5 );
    colorList.setFixedCellHeight( 15 );
    colorList.setSelectionMode(
    ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    c.add( new JScrollPane( colorList ) );
    // create copy button
    copy = new JButton( "Copy >>>" );
    copy.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
    // place selected values in copyList
    copyList.setListData(
    colorList.getSelectedValues());
    String s1 =(String)colorList.getSelectedValues();

    Since the JList method 'getSelectedValues' returns an object array you'll need to iterate through the array and cast each object in the array to a string as you access them.
    Object[] o = colorList.getSelectedValues();
    for(int count=0,end=o.length; count<end; count++) {
    String s = (String) o[count];
    Hope that helps
    Talden

  • Moving stuff from one JList to an other

    Hi,
    I'm trying to develop a JPanel with two JLists and two arrow JButtons to be able to move (!) stuff from the left JList to the Right and backwards. Both JLists have a ListCellRenderer that extend JLabel.
    Managed to do a 'copy' of selected values to the other JList,
    eg.
    public void addKeyWords(java.awt.event.ActionEvent actionEvent,javax.swing.JList allKeyWords,javax.swing.JList chosenKeyWords) {
    java.util.List chosenValues = java.util.Arrays.asList(chosenKeyWords.getSelectedValues());
    java.util.List selectedValues = java.util.Arrays.asList(allKeyWords.getSelectedValues());
    java.util.Set set = new java.util.HashSet();
    set.addAll(selectedValues);
    javax.swing.JList l = new javax.swing.JList(set.toArray());
    getChosenKeyWordsList().setModel(l.getModel());
    return;
    but can't figure out how to get stuff to disappear in the first JList when it is moved to the other JList nore how to enable the user to 'add' elements one at a time.
    Enyone?

    hi.
    what i do when i want to remove from the right side list:
    //get an array of indexes that needs to be removed.
    elements[] removedItems = getStrings(rightListData, selected);
    //copy all elements that do NOT need to be removed
    rightListData = utils.copyArrayWithoutIndex(rightData, selected);
    rightList.setListData(rightListData);
    same goes for left side.
    basically, i remove all selected elements from the array of rows, and re-set the list data model.
    HTH.

  • Need help in upfate of the jlist

    when i add somthing to the listmodel it doesnt apper on the list how to make it appear

    reset your JList data by call:
    setListData(Object[]�listData);
    or
    setListData(Vector�listData);

  • 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

  • JList(Vector) inside JScrollPane vanishes!

    Hi all, I have a problem thats driving me crazy, Im really stumped on this one;
    Im trying to update the GUI on a packet sniffer I wrote a while ago,
    I have a GUI class below as part of a larger program, this class containes a JList(Vector) inside a JScrollPane inside a JPanel inside a JFrame, I want this JList to be on the screen all the time, and grow dynamically as new elements are added to the Vector.
    Elements are added via an accessor method addPacket(Capture), you can assume the other classes in my program work fine.
    The problem is, the JFrame periodically goes blank, sometimes the scrollbars are present, sometimes not. After a while (sometimes) the JList reappears, containing the list of packets as it should, but it never lasts very long. Often it will disappear permanently.
    The class below is pretty short and simple, I really hope this is a simple and obvious mistake Ive made that someone can spot.
    Thanks,
    Soothsayer
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.InputStream;
    public class GUI extends JFrame
         Dimension screenResolution = Toolkit.getDefaultToolkit().getScreenSize();
         private InputStream fontStream = this.getClass().getResourceAsStream("console.ttf");
         Font outputFont;
         static final Color FIELD_COLOR = new Color(20, 20, 60);
         static final Color FONT_COLOR = new Color(150, 190, 255);
         private static JPanel superPanel = new JPanel();
         private static Vector<Capture> packetList = new Vector<Capture>(1000, 500);
         private static JList listObject = new JList(packetList);
         private static JScrollPane scrollPane = new JScrollPane(listObject);
         public GUI()
              super("LineLight v2.1 - Edd Burgess");
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setLocation(50, 10);
              try { outputFont = Font.createFont(Font.TRUETYPE_FONT, fontStream); }
              catch(Exception e) { System.err.println("Error Loading Font:\n" + e); }
              outputFont = outputFont.deriveFont((float)10);
              listObject.setFont(outputFont);
              superPanel.setPreferredSize(new Dimension(screenResolution.width - 100, screenResolution.height - 100));
              superPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
              scrollPane.setPreferredSize(new Dimension(screenResolution.width - 100, screenResolution.height - 100));
              scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
              scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
              scrollPane.setWheelScrollingEnabled(true);
              superPanel.add(scrollPane);
              this.add(superPanel);
              this.pack();
         public void addPacket(Capture c)
              this.packetList.add(c);
              this.listObject.setListData(packetList);
              this.superPanel.repaint();
    }

    I'm having basically the same problem, And how is your code different than the example in the tutorial???
    You can also read the tutorial section on "Concurrency".
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
    Start your own posting if you need further help.

  • How to scroll JList to bottom

    I have a JList on a JScrollPane, and it updates in real-time.
    As the data fills the pane, I want it to scroll to the bottom all the time,
    but it stays at the top. I update as follows:
    String voltString[]=new String[someNumber];
    // Set the strings to stuff--code omitted
    voltList.setListData(voltStrings);
    voltList.ensureIndexIsVisible(voltStrings.length);But it doesn't work. The API for ensureIndexIsVisible says something
    about a JViewPort, but I am not sure what it means--I have it on a
    JScrollPane, not a JViewPort.

    works OK like this
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing extends JFrame
      int counter = 0;
      javax.swing.Timer timer;
      public Testing()
        setLocation(200,100);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final DefaultListModel lm = new DefaultListModel();
        final JList list = new JList(lm);
        JScrollPane sp = new JScrollPane(list);
        sp.setPreferredSize(new Dimension(100,150));
        getContentPane().add(sp);
        pack();
        setVisible(true);
        ActionListener al = new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            lm.addElement(counter);
            counter++;
            list.ensureIndexIsVisible(lm.size()-1);
            if(counter > 100) timer.stop();}};
        timer = new javax.swing.Timer(100,al);
        timer.start();
      public static void main(String[] args){new Testing();}
    }

  • How to automatically show items in a JList

    I'm new to java and swing and I'm working with JList. I want to make the content of the list show automatically whenever a new item is added to the list model.
    The user clicks a button and a method perform some work periodically adding status message to the List model attached to the JList. All the messages appear when the method completes but I would like them to appear as it it running.
    I tried but this doesn't work:
    mList_Status.setListData(dlm.toArray());
    mList_Status.repaint();
    Is this a threading issue? Thanks!

    Is this a threading issue?Yes, you are doing all your work in the EDT, which is preventing the GUI from repainting itself. You need to use a separate Thread. Read the Swing tutorial on Concurrency for more information.

  • 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

Maybe you are looking for

  • After canceling a pre-order from iTunes I don't have the money credit back

    I recently pre-ordered an album from iTunes on my iPod Touch. (gift card) After about a week I decided that I'd rather get the actual physical disk from the store once it's released, so I canceled the pre-order and  I was told by the iTunes store tha

  • Trouble Connecting My MacBkPro to TV

    I have been watching Netflix stuff from my computer with a connection to my TV with the VGA mode. It has worked fine but just the other day the TV stopped detecting the signal from my MAc. I tried permission repair and Onyx to clean things up but no

  • 8i Personal Edition Download

    Somehow the file that I downloaded to install 8i Personal was corrupted and now I cannot unzip the file. I don't want to spend another day and a half downloading the file...is there anyway that I can have a cd sent to me? Sam

  • Offline Help Files for Lightroom 3.5?

    I understand that these offline help files do exist, but I'm unable to find them. Online help files are totally useless with the Broadband speed available in the sticks where I live! Will some kind soul please help?

  • Oradim.exe is not a valid win32 application

    Hi, While trying to install the new database i am getting the following error on windows 7 i executed the bat file as "Run as administrator" C:\Windows\system32>D:\app\username\product\11.2.0\dbhome_1\bin\oradim.exe -new-sid NEWDB -startmode manual -