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); } };
thanks for this piece of code.
ReplyDeleteits very tricky.
Ok basically this works, but using this approach disabling the tree gets you a pretty nice NullPointerException. To avoid this use
ReplyDeletesetBackgroundNonSelectionColor(new Color(0, 0, 0, 0)); on the renderer object instead. Same effect no NPEs.