Click here to Skip to main content
15,868,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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()))
			{
				//JOptionPane.showMessageDialog(null,"Same");
				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
Posted
Updated 28-Dec-22 22:19pm
v2
Comments
Richard MacCutchan 29-Dec-22 3:47am    
"My codings are correct but why this unusual problem occured"
Most likely because your coding is not correct. But how can we tell without seeing your code?
Member 12712527 29-Dec-22 4:11am    
Okay Sir I am posting all the codes in the Improve Question section
Richard MacCutchan 29-Dec-22 5:16am    
All you have done is dump a load of badly formatted code, which looks the same as the code in your previous question at How to add element to jlist and then how to add that jlist to jscrollpane...?[^].

We cannot guess where the problem occurs. Please use the Improve question link above, and add complete details, especially we need to know where it occurs and what happens.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900