void java.awt.Container.validate()
Validates this container and all of its subcomponents.
这个函数更新容器及其全部子控件,更新容器意味着重新布置它的子控件。布局相关的更改(例如设置子控件的大小位置,向容器添加新控件)会invalidate这个容器。需要注意,当前容器invalidate会自动导致它的父容器进行invalidate(详见Component.invalidate)。因此,要想恢复整个层次的有效性(validity),validate()这个函数应该由最高级别的父容器来调用。容器的validate()是一个费时的操作,故为了性能,程序员最好不要频繁调用它。比如,应该在对容器全部更改完成之后,只调用一次validate(),而不应该是每改动一下都validate一次。如果当前容器不有效,那就会调用它的invalidateTree()函数进行validate它的全部子控件。如果当前容器有效,那就啥都不做。
Validating a container means laying out its subcomponents. Layout-related changes, such as setting the bounds of a component, or adding a component to the container, invalidate the container automatically. Note that the ancestors of the container may be invalidated also (see Component.invalidate for details.) Therefore, to restore the validity of the hierarchy, the validate() method should be invoked on the top-most invalid container of the hierarchy.

Validating the container may be a quite time-consuming operation. For performance reasons a developer may postpone the validation of the hierarchy till a set of layout-related operations completes, e.g. after adding all the children to the container.

If this Container is not valid, this method invokes the validateTree method and marks this Container as valid. Otherwise, no action is performed.

==============
void java.awt.Container.invalidate()

这个函数使得容器失效,例如:容器的布局为layoutManager2,这个函数会调用layoutManager2.invalidateLayout(Container)。之后,这个函数把这个容器标记为“失效(invalid)”,并且把这个容器的各级父容器都标记为“失效(invalid)”。
Invalidates the container.

If the LayoutManager installed on this container is an instance of the LayoutManager2 interface, then the LayoutManager2.invalidateLayout(Container) method is invoked on it supplying this Container as the argument.

Afterwards this method marks this container invalid, and invalidates its ancestors. See the Component.invalidate method for more details.

===========================
void javax.swing.JComponent.update(Graphics g)

这个函数调用paint(),它不擦除背景。
Calls paint. Doesn't clear the background but see ComponentUI.update, which is called by paintComponent.
==========================
void javax.swing.JPanel.updateUI()

当观感改变之后,调用这个函数进行更新。
Resets the UI property with a value from the current look and feel.
=======================
void java.awt.Component.repaint()

重绘控件,如果是轻量级控件,这个函数立即调用它的paint()函数。否则,这个函数会立即调用它的update()函数
Repaints this component.

If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible.

Note: For more information on the paint mechanisms utilitized by AWT and Swing, including information on how to write the most efficient painting code, see Painting in AWT and Swing.

======================

涉及到重绘的,update()+repaint()足以应付一切情况。update()和invalidate()之后,不会立即引起重绘事件,用repaint()则能够立即重绘。

最新文章

  1. 2016-12-15 java开发工作中,尚未做的工作
  2. 我的ORM之三 -- 更新
  3. Android WebView Memory Leak WebView内存泄漏
  4. shell知识点
  5. 【水题递归】【HDU2044】我大沙茶了
  6. iOS苹果官方Demo合集
  7. C# 给枚举定义DescriptionAttribute,把枚举转换为键值对
  8. 阿里云服务器linux(cenos)下 jdk、tomcat的安装配置
  9. 微信小程序(有始有终,全部代码)开发--- 新增【录音】以及UI改进
  10. 【Java入门提高篇】Day8 Java内部类——匿名内部类
  11. 关于js中的json对象,json串,数组之间相互转换
  12. Netty中的连接管理
  13. Python--day07(数据类型转换、字符编码)
  14. 2.SSM整合_多表_一对一或多对一的增删改查
  15. Centos7修改时区
  16. 关于VMware虚拟机安装镜像时黑屏的解决办法
  17. [转]PostgreSQL命令行使用手册
  18. 五子棋 AI(AIpha-beta算法)
  19. Hadoop生态圈-大数据生态体系快速入门篇
  20. NOI1995石子合并&多种石子合并

热门文章

  1. Eclipse常用的十个方便的快捷键
  2. glibc-2.15编译error: linker with -z relro support required
  3. C#编程普通型计算器 经验与感悟
  4. poj3278 Catch That Cow
  5. fragment的切换(解决REPLACE的低效)
  6. jQuery学习之jQuery Ajax用法详解
  7. Oracle 中 decode 函数用法(转)
  8. iOS 关于版本升级问题的解决
  9. java多线程系类:基础篇:04synchronized关键字
  10. 兼容利器之X-UA-Compatible