JList not showing items or showing selectively.

Posted by Avrahamshuk on Stack Overflow See other posts from Stack Overflow or by Avrahamshuk
Published on 2011-01-12T20:51:24Z Indexed on 2011/01/12 20:53 UTC
Read the original article Hit count: 243

Filed under:
|
|
|

I have a Java Swing application using a JList to show some data from a DB.

I am using DefaulListModel as the data model for the list in this way:

void PopulateSoldiersList() 
{
      try
      {
           soldiersListModel = new DefaultListModel();
           for (Soldier i : myBackEnd.GetAllSoldiers())
           {
                 soldiersListModel.addElement(i);
           }
           this.listSoldiers.setModel(soldiersListModel);
      }
      catch (Exception ex) {// Error Message}
}

And for some reason, the list just stays empty...

I even did make sure at runtime that all the data is set up properly in the data model and even in the "dataModel" property of the JList!

In other place at the app i have a similar problem, but there, sometimes the list show few items from the model (but not all of them)

I have no idea where to go from here...

please help. Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about swing