Re: Jlist items not appearing occasionally



Allan Bruce wrote:
"IchBin" <weconsul@xxxxxxx> wrote in message news:VvacnW_PlKY18FPeUSdV9g@xxxxxxxxxx
Allan Bruce wrote:
I am adding entries to a JList via a DefaultListModel from a single thread but sometimes the entries do not show unless I modify the list. To give some context, I have an instant messenger application and on login, several users are added to the list. Sometimes the list appears fine in that all users are shown and selectable etc. however sometimes nothing shows on the list - if this is the case, when another user logs in (thus adding agin to the list) the list shows correctly with all users. I have code below to show how I am initialising the list and adding to it. Should I be doing anything more? Is there a way to force the contents of the list to refresh?

Thanks
Allan


// creation of list mList = new DefaultListModel(); mListBox = new JList(mList); mStatusBar = new JStatusBar(3); getContentPane().setLayout(new BorderLayout()); getContentPane().add(new JScrollPane(mListBox)); getContentPane().add(mStatusBar, BorderLayout.SOUTH);

// adding to list
mList.addElement(xiUser.userName()); // just a plane old String being added
Code looks fine. Don't think this could be the problem but you cold try

mList.add(mListBox.getModel().getSize(), xiUser.userName());

I would be concerned with the xiUser.userName() call.

This must be the problem.

Easy way to find out is to step trace it in a debugger.


The Strings are definately defined and have length >0 however I think it might be a swing/threads problem...
Allan



I am do ton's of JTable updates across multiple tables with no problem. Are you loading your GUI as below..

javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    SomeCcreateAndShowGUIMethod();
    }
});


--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________


'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)
.



Relevant Pages

  • Re: Jlist items not appearing occasionally
    ... but sometimes the entries do not show unless I modify the list. ... To give some context, I have an instant messenger application and on login, several users are added to the list. ...
    (comp.lang.java.help)
  • Re: Semi-OT: little-known/well-known terms in monolingual dictionaries
    ... of knowing how best to translate this word. ... of a word -- taking the context into account of course. ... Googling would help to some extent, but when I create my own user entries ... I'll mark the entries in my user entry so I know which dictionary/version ...
    (sci.lang.translation)
  • Re: Need help with import *.ldf
    ... If you are just adding 2 entries to the Turflist, ... Read my blog! ... Refer to the following site for ldifde help. ... I get the senderfilter.ldf file so i can modify it. ...
    (microsoft.public.exchange.admin)
  • Re: Context menu modifications
    ... > Here's more info on context menus. ... > Add or remove entries in the New objects list ... >>> Are you sre that you don't want to get rid of everything that Nvidia ... >>> Download and install ShellExView... ...
    (microsoft.public.windowsxp.general)
  • Re: Removing unwanted right click items from desktop folders?
    ... Manage the context-menu entries for files, folders, drives and Namespace ... context menu of a desktop folder in my WinXP Pro system. ... Regards from Mike, ...
    (microsoft.public.windowsxp.basics)