Click here to Skip to main content
12,349,148 members (56,050 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Java
Hi friends I am facing one problem
there is a jtable and a combobox, and when i select item from combobox it shows me correctly first one.
when i select item second time (any item) it shows me correctly.
but when i click on rows of table it shows me previously fetched data.
actually I am fetching data from data base

This is my code please help. thanks.

asrNoComboBox.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent evt) {
				// TODO Auto-generated method stub
				String nm=asrNoComboBox.getSelectedItem().toString();
				
				 DefaultTableModel model = new DefaultTableModel();
				 table = new JTable(model){ public boolean isCellEditable(int rowIndex, int colIndex) {
					  return true; //Disallow the editing of any cell
				  }};
				
				 model.addColumn("Asr No");
				 model.addColumn("Intex Error");
				 model.addColumn("Message Type");
				 while (model.getRowCount()>0){
					 model.removeRow(0);
					 }
				for(int i=0;i<IntexErrors.length;i++)
				{
					if(IntexErrors[i][0]!=null)
					if(IntexErrors[i][0].equalsIgnoreCase(nm))					
					{
						System.out.println(IntexErrors[i][0]);
						System.out.println(IntexErrors[i][1]);
						System.out.println(IntexErrors[i][2]);
						 model.addRow(IntexErrors[i]);
						
					}
				}
Posted 18-Sep-12 21:08pm
Edited 18-Sep-12 21:41pm
TorstenH.34.9K
v3
Comments
TorstenH. 19-Sep-12 3:42am
   
Holy! I added some line breaks and other stuff to your text.
Now it's kind of readable.
How should we figure your question when you mix up the text like that?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You are using class member variables in there.
Do not do that, you need to keep it all in the function. Otherwise an old reference will be held and your new click event will work with old data.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100