Skip to content
Advertisement

TableModelListener and multiple column validation

This is the first time for me to post here, so sorry if I made some mistake.

I am working on a JTable which column data have to verify some parameters, for example:

Column 3 values > 30
Column 4 values > 10
Column 5 values > 4

Also the first 2 columns are filled “automatically”, putting 0s in the rest of the columns.

If that data is correct, in the Column 5 I would show an image of a tick, otherwise, I would show an image of a warning.

For verifying this I use the following code

JavaScript

The problem of this code is that returns a Stack Overflow, and I don’t know how to handle this.

Is there any other way to implement some verifier on a table that implies multiple cells?

Thanks in advance.

Advertisement

Answer

The problem of this code is that returns a Stack Overflow, and I don’t know how to handle this.

The problem is that your code sets a value in the model listener so another tableChanged event is generated. Your code should be something like:

JavaScript

I don’t see a problem using a TableModelListener to dynamically set the value of a column based on data in another column. Here is a simple example:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement