• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting DecimalFormat in JTable

 
Roy Wira
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I have some float numbers to put in JTable. The problem is I need to make them all displayed with 4 digits behind zero, can anyone help me with this?

They need to be displayed 12.3400 and 12.3457 respectively in JTable.
Thank you for any help,
Roy
[ October 02, 2002: Message edited by: Roy Wira ]
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create your own cell renderer and do it there. Override this method:

public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column)
Put in number format code within this method. (See DecimalFormat)
 
Roy Wira
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, It works fine now.
Originally posted by Paul Stevens:
Create your own cell renderer and do it there. Override this method:

public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column)
Put in number format code within this method. (See DecimalFormat)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!