swing - java jlist doesn't display one of the items completely sometimes -


i having problems jlist. have scrollpane , added jlist it. sometime don't see first item in list.(i seeing behavior other items in list also)

i appreciate help.

thanks,enter image description here

here code snippet

-jlist creation:

    jallscrollpane = new jscrollpane();     jallscrollpane.getviewport().add(allnetlayer);     allnetlayer.setvisiblerowcount(3); 
  • i add items jlist in following method

     void additemtolist(string lay)  {         layerinit =1;         if(lay.compareto("all") ==0)         {              listdata.clear();         }         if(lay.compareto("done") == 0)         {              alllay.setlistdata(listdata);              jallscrollpane.updateui();         }         else         {              listdata.addelement(lay);         }         layerinit =0;   }    
  • gui creation:

     javax.swing.grouplayout jlogpanellayout = new javax.swing.grouplayout(jlogpanel); jlogpanel.setlayout(jlogpanellayout); jlogpanellayout.sethorizontalgroup(             ....             ....             .addcomponent(jallscrollpane, javax.swing.grouplayout.alignment.trailing, javax.swing.grouplayout.default_size, 200, javax.swing.grouplayout.default_size))             ....             ....         .addcontainergap()) );      jlogpanellayout.setverticalgroup(         ....         ....          .addcomponent(jallscrollpane, javax.swing.grouplayout.preferred_size, 190, javax.swing.grouplayout.preferred_size)          ....          ....         .addgap(20,20,20))))  ); jtabbedpane1.addtab("all", jlogpanel); 

your posted code messed up. it's difficult compile it.

the thing can

  • advice - read @mkorbel comment , take heart
  • use simpler use layouts - borderlayout, gridlayout, etc. or miglayout
  • use fire*(data changed) methods on swing's models, repaint()
  • you can use new jscrollpane(<panel inside>)
  • additemtolist should have single responsibility - add item list - conditions shouldn't there
  • you shouldn't reset whole list model data add 1 item
  • you can import - instead of writing every time javax.swing.grouplayout
  • you shouldn't create state when creating gui - layerinit

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -