Search code examples
javaswingjtabletablecellrenderercurrency-formatting

Format JTable column for currency


I have a JTable and I want a particular column to formatted as currency. If i put a number on that column like 3 it will show $3.00. i used TableCellRenderer but i'm not getting into it. Can anyone help ?

Thanks in advance.


Solution

  • Check out Table Format Renderers.

    It shows how to use a renderer to do simple formatting by using the Format class. It even supports a convenience method for formatting currencies.

    By the way in the last two questions that you posted and accepted an answer, there were better (simpler) answers that you could have used.