Sir in the constructor i have included 3 combo boxes, each adding 3 different file variable of the same source[ i.e. same path]
On running the values are shown correctly....
Also the codes in each of the itemStateChange event of the combo Boxes acts correctly.
Problem begins at this point....
When i select the first combo the related listbox shows the value but also the listbox associated with other two combo shows the same value as first one
Same is with other combos. Why each combo is linked with each other...?
What I have tried:
THe code in the constructor...
for(File f: fo.listFiles())
{
if(f.isAbsolute())
{
jComboBox2.addItem(f.toString());
f=null;
}
}
for(File d:fo.listFiles())
{
if(d.isAbsolute())
{
jComboBox4.addItem(d.toString());
d=null;
}
}
for(File q:fo.listFiles())
{
if(q.isAbsolute())
{
jComboBox6.addItem(q.toString());
q=null;
}
}
<pre>File fd=new File(fr.toString());
String gg="";
try
{
FileReader fread=new FileReader(fd);
BufferedReader in=new BufferedReader(fread);
String line=in.readLine();
char []po=line.toCharArray();
int ih=0;int pop=0;
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
DefaultListModel<string> model=new DefaultListModel<>();
JList b;JList c;JList kj;model.clear();
for(ih=0;ih<line.length();ih++)
{
="" joptionpane.showmessagedialog(null,po[ih]);
="" gg="" ;
="" while(po[ih]!="-" )
="" +="po[ih];
" ih++;
="" }
=""
="" model.addelement(gg);="" joptionpane.showmessagedialog(null,gg);
="" b="new" jlist(model);
="" b.setlayoutorientation(jlist.vertical);
="" b.setvisible(true);
="" b.addmouselistener(new="" mouseadapter(){
="" public="" void="" mouseclicked(mouseevent="" me)
="" if(me.getclickcount()="=1)
" jlist="" jb="(JList)me.getSource();
" int="" index="jb.locationToIndex(me.getPoint());//JOptionPane.showMessageDialog(null,index);
" if(index="">=0)
{
Object item=jb.getModel().getElementAt(index);
}
}
}
});
jsp=new JScrollPane(b,v,h);
jsp.setBounds(50,170, 180, 110);
jsp.setVisible(true);
this.add(jsp);
}
}
catch(Exception e)
{
System.out.println("111 "+e.getMessage());
}
likewise other two same coding in the constructor
now in the itemStateChange event
<pre>for(File fr:fp.listFiles())
{
try
{
FileReader fread=new FileReader(fr);
BufferedReader bread=new BufferedReader(fread);
if(fr.getName().equals(fq.getName()))
{
String gg="";
DefaultListModel<string> model1=new DefaultListModel<>();JScrollPane jsp4;
try
{
String line=bread.readLine();
char []po=line.toCharArray();
int ih=0;int pop=0;
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JList<string> ko;model1.clear();
for(ih=0;ih