What is the difference between revalidate() and repaint() in Java Swing is one of the popular Swing Interview Questions especially on Investment banks? Though both methods sound similar, there is a subtle difference between them. the revalidate() method instruct LayoutManager to recalculate layout and often called once new components are added or removed from Container. The revalidate() can also trigger to call to the repaint() method to repaint components which have changed i.e. width, height or any other visible property, which can affect layout. On the other hand repaint() method puts a paint request in AWT thread, for repainting of a component on which it has called.
Read more »This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here