Repaint()
Repaint() method just repaints the component. It is the method of Component class. Repaint() causes calls paint() method of a Component if it is a lightweight component. It is better to call the repaint method rather than paint method because painting system calls paint at appropriate time which coalesces multiple calls into one call. Another disadvantage of calling paint rather than repaint is it bypasses the double buffering mechanism.
Validate()
Before checking validate first we need to check when we say Component is valid what it means? It means that the Component coordinates has been determined and nothing is changed changing these coordinates. When the Component is created the valid property is false so we can say it as invalid as the coordinates hasn’t been determined. Validate() method validates the component by calling doLayout(). Validation is performed on Container and on its child components recursively which results in all the components to be laid out and validated. Validate() method is necessary when we remove the component and add it again.
Invalidate()
This method makes components invalid , along with all of its ancestor containers up to the
nearest validate root. Validate root can be any container which doesn’t change the size when their child components change size. This method need to call when components needs to have new layout to be done.
Revalidate()
When we call invalidate() it doesn’t automatically calls validate to make Components to be valid again. Revalidates calls invalidate first and then make components valid by calling validate method. Most swing components calls revalidate() method when we change the size of the components and call the repaint method.
'IT 실무 > JAVA' 카테고리의 다른 글
[Java] 파일 입출력(I/O)의 기본적인 이해 (385) | 2013.10.28 |
---|---|
[AWT&Swing] JTable (1188) | 2012.12.14 |
[자바] 작업 수행시간 체크를 위한 기본 소스 (121) | 2012.11.16 |
댓글