Swing: Multiple CellEditors for a column

Posted by Luhar on Stack Overflow See other posts from Stack Overflow or by Luhar
Published on 2010-04-08T15:37:30Z Indexed on 2010/04/08 15:53 UTC
Read the original article Hit count: 188

Filed under:
|
|

Hi,

In my JTable, I have two editable numeric columns. The editor for both columns extends AbstractCellEditor and uses a JFormattedTextField as an the editing component.

The problem is that the format for input depends on the value of another column in the row. If condition X is met, the number of fraction digits should be Y, otherwise they should be Y+2.

I attempted to override the getTableCellEditor(..) method to associate a TableCellEditor per row. See this example. However, since I have two editable columns, sharing a single TableCellEditor object per row gives some very odd results. I don't think this is an appropriate solution.

Any ideas on how to approach this would be much appreciated!

Thank you!

© Stack Overflow or respective owner

Related posts about java

Related posts about swing