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()则能够立即重绘。

java中的重绘的更多相关文章

  1. 【MFC】MFC中窗口重绘

    MFC中窗口重绘 摘自:http://blog.csdn.net/shuilan0066/article/details/5859057 在刷新窗口时经常要调用重绘函数 MFC提供了三个函数用于窗口重 ...

  2. IOS中对图片进行重绘处理的方法总结

    一.CGImageRef是什么 CGImageRef是定义在QuartzCore框架中的一个结构体指针,用C语言编写.在CGImage.h文件中,我们可以看到下面的定义: ? 1 typedef st ...

  3. MFC中窗口重绘

    搬家于CSDN 2015-05-14 MFC提供了三个函数用于窗口重绘 InvalidateRect(&Rect) Invalidate() UpdateWindow() 当需要更新或者重绘窗 ...

  4. WinForm中的重绘 - 按钮等控件的背景渐变色重绘

    注:brush通过起止坐标来控制重绘范围及方向.比如从上到下渐变时,brush第二个Point参数是左下角坐标. private void PaintGradientBackground(Button ...

  5. Java中可重入锁ReentrantLock原理剖析

    本文由码农网 – 吴极心原创,转载请看清文末的转载要求,欢迎参与我们的付费投稿计划! 一. 概述 本文首先介绍Lock接口.ReentrantLock的类层次结构以及锁功能模板类AbstractQue ...

  6. WinForm中的重绘 - 文本的重绘

    两种方式 TextRenderer.DrawText 注意:默认在每次绘制的文本左右有padding,即使参数中设置了TextFormatFlags.NoPadding也是一样,因此在分段绘制文本时( ...

  7. 【转】VC的MFC中重绘函数的使用总结(整理)

    原文网址:http://www.cnblogs.com/x8023z/archive/2008/12/09/mfc33.html 在刷新窗口时经常要调用重绘函数MFC提供了三个函数用于窗口重绘Inva ...

  8. JAVA 画图板实现(基本画图功能+界面UI)二、功能实现及重绘实现

    上篇博客中介绍了界面的实现方法,在这篇博客中将对每个按钮的功能的实现进行讲解并介绍重绘 首先肯定要添加事件监听机制了,那么问题来了,事件源对象是谁?需要添加什么方法?事件接口是什么? 1.我们需要点击 ...

  9. 如何在pyqt中使用 QStyle 重绘 QSlider

    前言 使用 qss 可以很方便地改变 QSlider 的样式,但是有些情况下 qss 无法满足我们的需求.比如下图所示样式: 如果直接使用 qss 将 handle 的内圆设置为透明背景,会看到 ha ...

随机推荐

  1. day 2 Linux目录结构

    Linux系统的目录结构的基本介绍: 1)在逻辑上的所有目录(包括目录下的子目录)都在最高级别的目录“/”下. 根(/)目录是Linux系统中所有目录的起始点(顶点),根下面的目录及子目录是一个有层次 ...

  2. Android 的提权 (Root) 原理是什么?

    作者:Kevin链接:https://www.zhihu.com/question/21074979/answer/18176410来源:知乎著作权归作者所有,转载请联系作者获得授权. Android ...

  3. aircack-ng抓握手包

    1.关闭影响进程 airmon-ng check kill 将要进入监听模式的无线网卡断开它已连接的AP 2.查看无线网卡的名字 ifconfig ,例如 wlan0 3.进入监听模式: airmon ...

  4. 用pygame学习初级python(二) 15.5.11

    闲得无聊,对第一版的东西做了一些修改,让它更像一个游戏,也具有一些可玩性. 项目的github地址:https://github.com/lfkdsk/BrainHole_pygame 1.人物类进行 ...

  5. 设计模式(java) 单例模式 单例类

    ·单例类 单实例类,就是这个类只能创建一个对象,保证了对象实例的唯一性. 1.单例模式( Singleton Pattern) 是一个比较简单的模式, 其定义如下:Ensure a class has ...

  6. C#语句

    C#控制语句 控制语句: goto语句 If语句 do while循环  for循环  while循环 switch语句 三元运算符   <test?><resultIfTrue&g ...

  7. 2014 UESTC暑前集训动态规划专题解题报告

    A.爱管闲事 http://www.cnblogs.com/whatbeg/p/3762733.html B.轻音乐同好会 C.温泉旅馆 http://www.cnblogs.com/whatbeg/ ...

  8. Unity3D粒子系统 合集

    http://www.cnblogs.com/qinyuanpei/p/3659513.htmlhttp://www.cnblogs.com/qinghuaideren/p/3597666.html

  9. u3d_Shader_effects笔记2 自定义surfaceDiffuseLight

    1.前面的心情 今晚7点半睡着后,9点半左右被吵醒.醒来后非常失落,感觉人生到底在追求什么,我又在追求什么.昨晚梦到妈妈了.最近不时会想到爷爷的去世.人世的险恶,良心的缺失.不过一切总要向前看,至少我 ...

  10. kali开启ssh

    Kali 2.0安装之后需要做的事--使用SSH进行远程登录   2015年8月11日,Kali官方推出了新的kali系统2.0版本,此次升级最大的特点就是系统界面的设计理念更加先进,以及系统的升级方 ...