• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to change font in JTable?

 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After converting from j2sdk-1.4 to j2sdk-1.3, I end up with big ugly fonts in my JTable. I can successfully change the column header fonts back withbut that doesn't change the font size in the table itself. Nor does:Anybody know how to change that stuff?
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to play with the TableCellRenderer and the method public Component getTableCellRendererComponent(...). Basically you need to return a JLabel after setting the font you needed. Having said that, it is unnecessary to do all this work for the assignment.
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sai. I've determined that the problem is that I'm writing the cells as HTML, and 1.3 doesn't do HTML quite like 1.4. The reason I went to HTML was that I wanted to do some fancy formatting- however, I can do all that with a custom TableCellRenderer as you suggest, something like:And yeah, I know all this isn't really "necessary."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic