I hope I will get help, I will ask as general question:
I am using a JList
, and due to the JList
not have a (value,text) (so I can display text and use the value in my code). Because of this leak I create List
of object (myList), that work parallel with the JList
. Every item I add to JList
I add to myList
, so the same index will contain the same info in the two objects (JList and mylist)
I use the JList.getselectedindex()
method to get the index and use it in myList
to pup information...
The problem: is when I select value, the next value of the myList
is overridden with the first value!!!
Is this problem known?
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
Here if file exists I just update the new text in the JList
and set the current file
The select of JList
is:
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
It works fine, but when I have two items in JList
if I select any, the other is overridden!!!