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!
You can solve it by creating yet another TableCellEditor which will delegate to either of its two subcontractors: the instances of your current cell editors. You need to register this uber-celleditor with the column and let it delegate whenever it is used by Swing.