Here is the AddList code that seems to be flawed

天涯浪子 提交于 2019-12-11 15:29:51

问题


I previously asked this question: Code that works on Windows Laptops but not on Mac for some reason. After looking at the comments, it seems I should've instead posted the code for AddList along with this question. This is the code for AddList

public List addList(String words,int left, int top, int width, int height, ItemListener listener)
   {
       List newComp = new List();
       while (words.length()>0)
       { int s = words.indexOf("|");
         if (s<0)
         { newComp.add(words);
           words = "";
         }
         else
         { newComp.add(words.substring(0,s));
           words = words.substring(s+1);
         }
       }
       add(newComp);
       newComp.setBounds(left,top,width,height);
       if (listener!=null)newComp.addItemListener(listener);
       return newComp;
   }

来源:https://stackoverflow.com/questions/55080532/here-is-the-addlist-code-that-seems-to-be-flawed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!