Java JTree Color updateComponentTreeUI(Component c)

Here you can find the source of updateComponentTreeUI(Component c)

Description

A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel.

License

LGPL

Parameter

Parameter Description
c UI component.

Declaration

public static void updateComponentTreeUI(Component c) 

Method Source Code


//package com.java2s;
/*//  w  w  w .  j  a  v  a2  s. c o m
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    /**
     * A simple minded look and feel change: ask each node in the tree
     * to <code>updateUI()</code> -- that is, to initialize its UI property
     * with the current look and feel.
     *
     * @param c UI component.
     */
    public static void updateComponentTreeUI(Component c) {
        updateComponentTreeUI0(c);
        c.invalidate();
        c.validate();
        c.repaint();
    }

    /**
     * Repaints UI tree recursively.
     *
     * @param c UI component.
     */
    private static void updateComponentTreeUI0(Component c) {
        if (c instanceof JComponent) {
            JComponent jc = (JComponent) c;
            jc.invalidate();
            jc.validate();
            jc.repaint();
            JPopupMenu jpm = jc.getComponentPopupMenu();
            if (jpm != null && jpm.isVisible() && jpm.getInvoker() == jc) {
                updateComponentTreeUI(jpm);
            }
        }
        Component[] children = null;
        if (c instanceof JMenu) {
            children = ((JMenu) c).getMenuComponents();
        } else if (c instanceof java.awt.Container) {
            children = ((java.awt.Container) c).getComponents();
        }
        if (children != null) {
            for (int i = 0; i < children.length; i++)
                updateComponentTreeUI0(children[i]);
        }
    }
}

Related

  1. getTreeBackground()
  2. setComponentTreeBackground(Component c, Color color)
  3. updateAllComponentTreeUIs()
  4. updateComponentTreeUI(JComponent c)
  5. updateComponentTreeUI(Window window)
  6. updateComponentTreeUI0(Component c)