Article View: borland.public.jbuilder.java.language
Article #16731Re: Getting the current JTree font
From: Richard Wilkman
Date: Mon, 25 Jan 1999 00:00
Date: Mon, 25 Jan 1999 00:00
62 lines
2445 bytes
2445 bytes
Leo: JTree doesn't set a font in it's constructor. In fact, if you walk the hierarchy you see that you are really calling java.lang.Component.getFont() which returns null if a font hasn't been set on the Component(). In fact, Component.setFont() doesn't look like it's been overridden at all. Looking more in the source you'll see that the font member of Component is null if there is no peer for the font (earlier releases of the JDK would get the system font or some such, but as peers disappear, so does this behaviour. Not sure how you'll get the "default" font, now. Since the default font is consistent (or seems to be), the only time I can see using your code is to change it. In that case, I'd catch the null and set the font to whatever. FWIW, most of the font handling for JDK 1.2 is handled via the Java2D stuff (part of the reason that UI is so very much slower). There may be an answer down those lines wrt: "default". -Rich Leo Cohen wrote: > > I have created a JTree with > > JTree jTree = new JTree(); > > and then try to get its font with > > Font font = jTree.getFont(); > > This produces font = null. > > How do I get the current, presumably default, font for JTree? > -- > Leo Cohen > > 116-1 Howard Drive > Charlottesville, VA 22903 > > 804-243-8922 (UVA) > 804-244-4648 (home) > 804-244-7922 (fax) > lcohen@cs.virginia.edu -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Rich Wilkman Senior Quality Assurance Engineer Borland JBuilder Team If you see something that looks like an opinion up there, it's mine and mine alone. Mail sent to me from the newsgroups won't bounce but will be ignored. If I have time, I'll respond, but you have a better chance if you confine your posts to the newsgroups =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Technical Details
Message-ID:
<36ACFA43.5028F637@inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<36ACC165.4F58865A@cs.virginia.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,82eb0e8f536b4c8e X-Google-Attributes: gidf74b3,public From: Richard Wilkman <rwilkman@inprise.com> Subject: Re: Getting the current JTree font Date: 1999/01/25 Message-ID: <36ACFA43.5028F637@inprise.com> X-Deja-AN: 436876864 Content-Transfer-Encoding: 7bit References: <36ACC165.4F58865A@cs.virginia.edu> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language