Here is the AddList code that seems to be flawed

2019-08-17 19:08发布

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;
   }

0条回答
登录 后发表回答