• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to change font in JTable?

 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
reply
    Bookmark Topic Watch Topic
  • New Topic