/**
* The class to handle the formatting of the double values for JTable cells.
*/
-public class DecimalFormatTableCellRenderer extends
- DefaultTableCellRenderer
+public class DecimalFormatTableCellRenderer extends DefaultTableCellRenderer
{
private DecimalFormat formatter;
{
significantFigureBuilder.append("0");
}
- formatter = new DecimalFormat(fractionFormater
- + significantFigureBuilder.toString());
+ formatter = new DecimalFormat(
+ fractionFormater + significantFigureBuilder.toString());
}
else
{
super.setHorizontalAlignment(JLabel.RIGHT);
}
+ /**
+ * Adapts the default method to ensure that double values are formatted for
+ * display
+ */
@Override
- public Component getTableCellRendererComponent(JTable table,
- Object value, boolean isSelected, boolean hasFocus, int row,
- int column)
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column)
{
- if (value == null)
- {
- return null;
- }
-
- value = formatter.format(value);
+ value = value == null ? "" : formatter.format(value);
return super.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);