File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to change font in JTable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "How to change font in JTable?" Watch "How to change font in JTable?" New topic
Author

How to change font in JTable?

Thomas Fly
Ranch Hand

Joined: Sep 09, 2002
Posts: 164
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?


Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
Sai Prasad
Ranch Hand

Joined: Feb 25, 2002
Posts: 560
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

Joined: Sep 09, 2002
Posts: 164
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."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change font in JTable?