File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTree font size question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree font size question" Watch "JTree font size question" New topic

JTree font size question

Joe Crew
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
I'm using jdk118 and swing 111. I've created a JTree I've also created new [+] and [-] signs that expand and collapse a branch node. I made new ones so they can be larger than standard. I've also created a graphic that replaces the windows system folder icon for nodes that contain children. Again no problem to create it and I created it so it would be larger. Now I want to change the font size to a larger font. I used the typical:
Font tf = new Font("sansserif",Font.PLAIN,16);
Again this works, as does everything else does. As you can see from my description above, I am trying to make everything in the JTree larger, the folder icons, the expand/collapse icons, and the font. All of the code works but there is one thing that does not work. The spacing between the text, icons, and/or text strings. For example, say there is 1/4 inch of an inch of space to put you text on a line in the jtree. If I create a font of 24, which I would like to use, the text from one node starts overlapping the lines below and above it. The 1/4 inch space does not increase. The text and icons all over lap. If I create a [+] icon that is over 17 pixels, the icons start overlapping each other. I thought by creating new icons and larger text, the space between each line in the jtree would expand and accomodate them but it hasn't. Has anyone experienced this? Do you have any work arounds? Anything you can tell me on this subject would be appreciated.
Joe Crew
I agree. Here's the link:
subject: JTree font size question
It's not a secret anymore!