๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #8884

Re: JTree and RootHandles

#8884
From: John P. McGrath
Date: Tue, 11 Jul 2000 00:00
38 lines
1915 bytes
On Sun, 9 Jul 2000 15:54:46 +0200, Jean-Fran๏ฟฝois Leroux wrote:

> I'd like to change the RootHandles picture in a jTree.
> I know I can do it for leaves or root, but is it possible
> for the handles themselves ?
>
> I saw an app. that used the Metal l&f where the tree had
> arrows and folders instead of those blue "handles". What's
> the trick ?

These sort of customizations often have to be through the UI delegate 
(i.e. the look-and-feel class).  The TreeUI class does not have a 
property for this, but I looked at the source code, and it appears as if 
the BasicTreeUI class does.  All of the common look-and-feels are based 
on BasicTreeUI, so maybe adding something like this to your JTree 
initialization would work:

    if ( tree.getUI() instanceof BasicTreeUI ) {
        BasicTreeUI ui = (BasicTreeUI) tree.getUI();
        ui.setExpandedIcon( expandedIcon );
        ui.setCollapsedIcon( collapsedIcon );
    }

If you want to change the expanded / collapsed for all JTrees in the VM, 
you could try setting the property in UIDefaults.  This would have to be 
done before you created your first JTree.

    UIDefaults defaults = UIManager.getDefaults();
    defaults.put( "Tree.expandedIcon", expandedIcon );
    defaults.put( "Tree.collapsedIcon", collapsedIcon );

I have not tried this, so I cannot say for sure that it will work.  Give 
it a try and let us all know how it works.

-- 
Regards,

John McGrath
Technical Details
Message-ID: <MPG.13d4789fed4e2ab7989a2a@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8k9vi7$fc813@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,30dc234facd82a1a
X-Google-Attributes: gid111d45,public
From: John P. McGrath <JPMcGrath@fast.net>
Subject: Re: JTree and RootHandles
Date: 2000/07/11
Message-ID: <MPG.13d4789fed4e2ab7989a2a@forums.borland.com>
X-Deja-AN: 644914815
References: <8k9vi7$fc813@bornews.borland.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing