Friday, April 20, 2007

Making a JTree transparent

To make a JTree completely transparent (i.e even after the tree.setOpaque(false) leaves the leaf nodes with white part.. The below code removes even that and makes it totally transparent).

DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
    public Color getBackgroundNonSelectionColor() {
        return(null);
    }

    public Color getBackground() {
        return(null);
    }
};