Java JTree Color updateComponentTreeUI0(Component c)

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

Description

Repaints UI tree recursively.

License

LGPL

Parameter

Parameter Description
c UI component.

Declaration

private static void updateComponentTreeUI0(Component c) 

Method Source Code


//package com.java2s;
/*/*from w  w w  . j a  v  a  2 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 {
    /**
     * 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]);
        }
    }

    /**
     * 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();
    }
}

Related

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