• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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 ?
 
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
 
Marshal
Posts: 59430
187
  • 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.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!