• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Column value is getting reset to zero automatically in Jtable

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my window,i have certain combo boxes which has dynamic values fetched from database.In particular,i have an 'ADD' button which i clicked will show a window having only a combobox with dynamic values.with actual scenario,if we select any value from that combobox,a row with 3 columns will be created with 1st column being the selected value from the combo box and the other two being zeros.I can give values to the other two columns(integer values only).After entering the value of 3rd row,3rd column when i added another value from the combo box by clicking the 'ADD' button,it creates another row with 3 cols(samething as i said previously).But the value of 3rd row & 3rd column automatically changes to zero.

Please help me to resolve this problem.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post your SSCCE demonstrating the problem.
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Assume a combo box which has dynamic values fetched from database.If you select any of the value,a row will be created with 3 cols.
2. Follow it for all the values in the combo-box

Please see the attachment for table structure.

3. When i followed the same step for entering 4th column,the cell value of 3X3(3rd row,3rd column) automatically becomes zero.
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Attachment are here.Kindly download the attachments.
Table-format.JPG
[Thumbnail for Table-format.JPG]
Table structure
errorpage.JPG
[Thumbnail for errorpage.JPG]
error page
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see a SSCCE anywhere...
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Mr.Rob Camick

Could you please tell me,what you exactly need from me.I can do it precisely for you to understand correctly.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the link provide and post the simple code that demonstrates the problem.
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Combobox having values A,B,C,D,E etc (dynamic values from Database).If you select 'A',one row will be created as follows

Value selected from Combobox Percent No of items
A 67 43

2. We can create any number of rows,until the combo box value becomes empty(as it it dynamic).

3. When i tried to create 4th row,the row is created but the cell value of 3rd row,3rd column automatically reset to zero.

4. Its working fine for the next rows.The error is with 3rd row.The loops and conditions are generic.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a link => http://sscce.org/
Click on it.
Read it and understand what Rob is meaning when he says SSCCE.
Then post your code which demonstrates the problem.
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This method gives the values in the combobox.once you selected a value in the combo,the left value will be calculated

EventHandler:
if (selectedValue != null) {
ThresholdStatistics stat = new ThresholdStatistics(detailedThreshold, selectedValue); /* detailedThreshold - value from the bean file,selectedValue - value selected from the combo */
getStatisticsTableModel().addStatistics(stat);/* Add a new row */

}
}
TableModel:

public void addStatistics(ThresholdStatistics stat) {
rows.addElement(stat);
count++;
fireModelChanged(new TableModelEvent(this,
rows.size()-1,
rows.size()-1,
TableModelEvent.ALL_COLUMNS,
TableModelEvent.INSERT));
}

ModelFile:

public static String[] getStatsLeftForThreshold(ThresholdDetailData threshold) {
Vector stats = null;
for (int i=0; i<StatsByThresholdTypes.length; i++) { /* StatsByThresholdTypes - dynamic values in the combobox
if (StatsByThresholdTypes[i][0].equals(threshold.getTypeCode())) {
stats = new Vector(StatsByThresholdTypes[i].length);
for (int j=1; j<StatsByThresholdTypes[i].length; j++) {
if (!isStatPresentInThreahold(threshold, StatsByThresholdTypes[i][j])) {
stats.addElement(StatsByThresholdTypes[i][j]);
}
}
i = StatsByThresholdTypes.length;
}
}
if (stats == null || stats.size() == 0) {
return null;
}
else {
String statStrings[] = new String[stats.size()];
for (int i=0; i<statStrings.length; i++) {
statStrings[i] = (String)stats.elementAt(i);
}
return statStrings;
}
}
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you even bother to read the contents of the link?
From the SSCCE page,


It is important to ensure that the code you relate to others can be 'copied, pasted, compiled, run' so that they can help you quickly and with a minimum of fuss.
This means that after the code has been copied, pasted and compiled by those helping you, they can run it and see the results for themselves...


The code you have posted, does it meet this criteria? Do you understand all the points given on the SSCCE page?
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am very sorry that i cant deliver any code over here,as its a violation.Also it involves MVC architechture,wherein i need to send you all client.model & server codes.

Can you please suggest me why this problem exists atleast.If you want any more explanation i am ready to explain you in brief.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

wherein i need to send you all client.model & server codes.



No. That is the point of creating a SSCCE. We DON'T want to see you client/server code. We want you to post a simple example that demonstrates the problem. Your problem is with a JTable not the client/server connection. You can just hard code the data in the table.

Can you please suggest me why this problem exists atleast.



Have you tried the example from the Swing tutorial. The code found there works perfectly. So the problem is with your code. We are not mind readers we can't guess why your code is different than the code from the tutorials. So if you want help you need to make the effort to create a SSCCe.
 
Gokulakannan Vasu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Rob Camick

if you want help you need to make the effort to create a SSCCe.



Sure dude...This is the first time i am into this.Surely i will correct my faults...!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic