Java examples for Swing:JComponent
Repaints the parent of the given component.
//package com.java2s; import javax.swing.JComponent; import javax.swing.SwingUtilities; public class Main { /**// w w w . ja v a2 s . com * Repaints the parent of the given component. If the parent is null, the component itself is repainted. * * @param component The component whose parent will be repainted. */ public static void repaintParent(JComponent component) { // Get the parent of the component. JComponent parentComponent = (JComponent) SwingUtilities .getAncestorOfClass(JComponent.class, component); // Could we find a parent? if (parentComponent != null) { // Repaint the parent. parentComponent.revalidate(); parentComponent.repaint(); } else { // Repaint the component itself. component.revalidate(); component.repaint(); } } }