My DateEditor returns a string; The first code block installs the editor and overrides it to return a string instead of a date. The problem is that it affects the String.class columns as well as the java.sql.Date columns. I can manage this by creating an editor for the string that uses a masks and does not include the "-" date formate character. However, I wonder if there is a way to make the date editor specific to Date columns. May be, casting the date string to date and having the editor returning a date type instead of a String? Is there any way to do this? It seems complex for the case where the returned value is null. Any ideas on how to do this? Thank you.
The thing is that if I want for my dates to be editable I have to return a String in getColumnClass(int col) method; therefore the editor has to be installed with String.class input. If I return Date in getColumnClass and install the editor with Date.class input, the cell is not editable; and it makes sense because the editor formats a string gets a string from getText() and returns a string. The only solution I see is to create a mask editor for the strings; this works; but I do not understand why. What am I missing?
I copied your code and made some modifications and it works for me.
1) First of all, the call to setting the editor can be simple. I don't understand why you loop through and set it in a complicated way. I have done this:
where DATE_FIELD is a constant(int) pointing to the column number.
2) I see that in the getColumnClass, you are making a decision based on the type. I have changed it to make it based on the column number. If you can follow a similar/simpler mechanism, that should work for you.
Note that, I have used the rest of the code as it is (including the editor, DateField, DateDocument) and it works fine for me.