Click here to Skip to main content
12,957,526 members (59,996 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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() {
			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){
				for(int i=0;i<IntexErrors.length;i++)
Posted 18-Sep-12 21:08pm
Updated 18-Sep-12 21:41pm
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
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.

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
OriginalGriff 6,994
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,170
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
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