Click here to Skip to main content
Sign Up to vote bad
good
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:08
Edited 18 Sep '12 - 21:41
TorstenH.29.4K

Comments
TorstenH. - 19 Sep '12 - 3:42
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

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
Your Filters
Interested
Ignored
     
0 OriginalGriff 208
1 Maciej Los 156
2 Santhosh G_ 155
3 Richard MacCutchan 145
4 Tadit Dash 140
0 Sergey Alexandrovich Kryukov 10,264
1 OriginalGriff 7,937
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,135


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid