Java Swing Jtable issue: how to table cell will be blank when the column
class is float or double
I have a jtable which model was extended to abstracttablemodel. It has 4
columns. First two columns hold string and last two columns hold double
type data. The last 2 columns displays 0.0 when the data is Null;
But I want to display it as Blank when the value is null or 0; And when I
will edit the cell and type any numerical value it will set double data
type value with precision point.
A solution may be that to change in getValueAt(int rowIndex, int
columnIndex) method and return " " when columnIndex is 3 and 4. But it
creates another problem. When I edit the cell it return String value and
required to parse the string value to double at setValueAt(Object value,
int row, int col) method with Double.parseDouble(value.toString());
But I think it is not wise or correct to parse the string value to Double;
I think setCellEditor may be a good solution. But I cant understand how to
set a celleditor to double data type
mytable.getColumnModel().getColumn(3).setCellEditor(???);
Could you give any solution.
No comments:
Post a Comment