Example usage for javax.swing JComponent paintImmediately

List of usage examples for javax.swing JComponent paintImmediately

Introduction

In this page you can find the example usage for javax.swing JComponent paintImmediately.

Prototype

public void paintImmediately(Rectangle r) 

Source Link

Document

Paints the specified region now.

Usage

From source file:Main.java

/**
 * Forces an immediate repaint of a component and all of its children.
 *
 * @param component/*from   w  w  w .  j  av  a2 s  .  c  o m*/
 */
public static void paintImmediately(Component component) {

    // Paint the component
    if (component instanceof JComponent) {
        JComponent jcomponent = (JComponent) component;
        jcomponent.paintImmediately(jcomponent.getBounds());
    }

    // Recursively paint children
    if (component instanceof Container) {
        Container container = (Container) component;
        int numberOfChildren = container.getComponentCount();
        for (int i = 0; i < numberOfChildren; i++) {
            Component child = container.getComponent(i);
            paintImmediately(child);
        }
    }
}