我希望我能得到帮助,我会问一般问题:
我正在使用 a JList,并且由于JList没有 (value,text) (所以我可以显示文本并在我的代码中使用该值)。由于这个泄漏,我创建List了对象 (myList),它与JList. 我添加到的每个项目都JList添加到myList,因此相同的索引将包含两个对象(JList 和 mylist)中的相同信息我使用该JList.getselectedindex()方法获取索引并将其myList用于 pup 信息...
问题:  当我选择值时,下一个值myList被第一个值覆盖!!!这个问题已知吗?
    mod_mp = new ModelMAPPING();   objects cotain values that ot exist in  jList                                                             
    msgF.setTo(incom.userID);/////// set parter!
    if(isExCon==-1) {
        // not exist                                           
        mod_mp.to = incom.userID; // incom is object that incom from another program
        mod_mp.SetCovFile(incom.userID+".html");
        mod_mp.ConvName = incom.getBody();
        boolean added= model_list.add(mod_mp);   // add to mylist
        if(added) System.out.println(mod_mp._Hfile + " added");
        model.addElement(mod_mp.ConvName);// add to Jlist by model
        HestoryFile(Htmlhead+tohis,mod_mp._Hfile);//create _Hfile and write to it:"tohis" string.
    } else { //exist@
        // note isExcon return the index if exist else -1
        model_list.get(isExCon).ConvName=incom.getBody();
        mod_mp.SetCovFile(model_list.get(isExCon)._Hfile);
        HestoryFile(tohis, model_list.get(isExCon)._Hfile);
    }//end else
在这里,如果文件存在,我只需更新中的新文本JList并设置当前文件
的选择JList是:
msgF.setTo (model_list.get(jList2.getSelectedIndex()).to); // set that we will send To...
mod_mp.SetCovFile(model_list.get(jList2.getSelectedIndex())._Hfile);//set the file
jLabel5.setText( bringFromFile(mod_mp._Hfile));//tell the label to read that file
它工作正常,但是当我有两个项目时,JList如果我选择任何一个,另一个会被覆盖!!!
