Java JTree Implementation

58 Views Asked by At

I'll be brief; I'd like to change the color of a JTree from the Metal LF's default blue to a gray. I've already looked at a ExtendedJTreeCellRenderer to no avail. Can this be done with UIManager, if not can it be done without having to custom icon the tree? I have 10+ years with Java, thanks.

Screenshot

        public static class ExtendedJTreeCellRenderer extends DefaultTreeCellRenderer
        {
            @Override
            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus)
            {
                JComponent c = (JComponent) super.getTreeCellRendererComponent(tree, value, isSelected, expanded, leaf, row, hasFocus);

                Graphics graphics = c.getGraphics();

                if(graphics!=null) graphics.setColor(Color.GRAY);

                c.setForeground(new Color(140,140,140));

                c.setBackground(new Color(8,8,8));

                c.setFont(new Font("Georgia", Font.PLAIN, 12));

                c.setOpaque(true);

                //

                this.setClosedIcon(new ImageIcon("images\\folder001.png"));

                //this.setOpenIcon(new ImageIcon(""));

                //this.setLeafIcon(new ImageIcon(""));

                //

                return c;
            }
        }
0

There are 0 best solutions below