• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to format the value in the table model?  RSS feed

 
alex ja
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I get the value from database and display in table , price value will show 6 decimal and date value will show date and time.
What to do to show only 2 decimal places and only date e.g. 1/1/2014 in the table ?
 
Jacob Anawalt
Ranch Hand
Posts: 64
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the TableCellRenderer, it is handy for formatting by column or type.

https://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

We usually discuss table models in our GUIs forum, so I shall move you there.
 
alex ja
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how it work ;(
 
Jacob Anawalt
Ranch Hand
Posts: 64
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Working through the examples on that page I linked starting from the top through the renderer section should help you see how they work.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!