Here you can find the source of invokeRepaintOnLayeredRoot(Component leaf, boolean everything)
public static void invokeRepaintOnLayeredRoot(Component leaf, boolean everything)
//package com.java2s; //License from project: LGPL import java.awt.*; import javax.swing.*; public class Main { /**/*from w w w. j ava2 s. c om*/ * If the given component is part of a JLayeredPane the lowest layer * of that JLayeredPane is used for the repaint; otherwise the component itself. * The repaint area is restricted to the leaf area; exception: flag everything is true. */ public static void invokeRepaintOnLayeredRoot(Component leaf, boolean everything) { // very dodgy workaround for being in a layered pane Component con = leaf.getParent(); if (con != null && con instanceof JLayeredPane) { JLayeredPane lp = (JLayeredPane) con; Component[] cs = null; synchronized (leaf.getTreeLock()) { cs = lp.getComponentsInLayer(lp.lowestLayer()); } if (cs != null && cs.length > 0) con = cs[0]; else con = leaf; // otherwise, when repaint is invoked normally // while we are in a higher layer of a layered pane // display flickers sometime } else { con = leaf; } if (everything || con == leaf) con.repaint(); else { Rectangle r = leaf.getBounds(); con.repaint(r.x, r.y, r.width, r.height); } } }