User Code: Using the Windows JTree Icons in Any Look and Feel

Thursday May 17th 2001 by Steve Rylander
Share:

Gamelan user Rylander has a tip to help you keep the same "look and feel" of JTree icons in different environments.

Here's how you can use the expand and collapse node icons (on a JTree) from the Windows "look and feel" within another look and feel.

Place the following lines at the beginning of your application:

UIManager.put("Tree.expandedIcon",  new WindowsTreeUI.ExpandedIcon()); 
UIManager.put("Tree.collapsedIcon", new WindowsTreeUI.CollapsedIcon());

Also, include the following import in the class: import com.sun.java.swing.plaf.windows.*;

Any JTree objects will now use the plus and minus icons!

This article was contributed by Steve Rylander.

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved