🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Getting the current JTree font

#16739
From: Richard Wilkman
Date: Tue, 26 Jan 1999 00:00
111 lines
4186 bytes
Leo:

Obviously there is some "default" in use, but maybe deep down in the
JDK code it simply does the null check and picks something to use.  If
this can't be consistent, I'd expect it to still preserve the "null"
value until over-ruled by a user action.  Outside of JDK 1.2, you
really only have the four fonts on the Java side.  How they map to
what is displayed will be dependent on the target machine (and it can
be different on each Win32 machine, which makes this kind of thing
really a PITA if you are trying to create consistent UI).

-Rich

Leo Cohen wrote:
> 
> 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

-- 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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: <36ADE93C.C3A90C19@inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36ACC165.4F58865A@cs.virginia.edu> <36ACFA43.5028F637@inprise.com> <36ADDD34.CEDC57FC@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/26
Message-ID: <36ADE93C.C3A90C19@inprise.com>
X-Deja-AN: 437153017
Content-Transfer-Encoding: 7bit
References: <36ACC165.4F58865A@cs.virginia.edu> <36ACFA43.5028F637@inprise.com> <36ADDD34.CEDC57FC@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