🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16736

Re: Getting the current JTree font

#16736
From: Leo Cohen
Date: Tue, 26 Jan 1999 00:00
81 lines
2943 bytes
Rich: Thanks for the note; it's most informative. The reason I thought
there would be a default font is because my tree displays but I set no
font for it.

Leo.

Richard Wilkman wrote:
> 
> 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
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-- 
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
Technical Details
Message-ID: <36ADDD34.CEDC57FC@cs.virginia.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36ACC165.4F58865A@cs.virginia.edu> <36ACFA43.5028F637@inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,82eb0e8f536b4c8e
X-Google-Attributes: gidf74b3,public
From: Leo Cohen <lcohen@cs.virginia.edu>
Subject: Re: Getting the current JTree font
Date: 1999/01/26
Message-ID: <36ADDD34.CEDC57FC@cs.virginia.edu>
X-Deja-AN: 437128522
Content-Transfer-Encoding: 7bit
References: <36ACC165.4F58865A@cs.virginia.edu> <36ACFA43.5028F637@inprise.com>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language