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. Spring MVC @ResponseBody返回中文字符串乱码问题

    朋友做小项目练手的时候遇到的,着实让他郁闷够呛..这个问题的确很恶心.. 项目中引用的json包,直接用@ResponseBody注解返回json字符串..有关这个的乱码问题网上很多,各种花样各种转码 ...

  2. 关于using关键字

    使用C#访问数据库资源需要如下几步: SqlConnection con=new SqlConnection(str); try { con.Open(); //略 } catch(Exception ...

  3. KSFramework:Unity3D开发框架快速入门

    KSFramework知识 https://github.com/mr-kelly/KSFramework KSFramework是一个整合KEngine.SLua和一些开发组件组成的全功能Unity ...

  4. IIS7.5中神秘的ApplicationPoolIdentity

    IIS7.5中(仅win7,win2008 SP2,win2008 R2支持),应用程序池的运行帐号,除了指定为LocalService,LocalSystem,NetWorkService这三种基本 ...

  5. Java的注解机制——Spring自动装配的实现原理

    http://www.cnblogs.com/Johness/archive/2013/04/17/3026689.html

  6. noip模拟赛(一)密码

    密码 (pasuwado.pas/c/cpp) [问题描述] 哪里有压迫,哪里就有反抗. moreD的宠物在法庭的帮助下终于反抗了.作为一只聪明的宠物,他打算把魔法使moreD的魔法书盗去,夺取mor ...

  7. 将pdf文件通过itunes直接拖到ipad的ibooks里面

    开始不太清楚进行过什么设置,使得以前可以直接通过拖动的方式复制pdf文件到ipad里面的方法不管用了.在帖子http://bbs.weiphone.com/read-htm-tid-864091-pa ...

  8. FiveChess笔记

    //为0,表示该位置没有棋子:1表示该位置下过黑子:2白子 int[][] allChess = new int[19][19];//同时还通过下标记录了棋子的相对位置 1.对话框: 确认对话框(0是 ...

  9. JS中new都是干了些什么事情

    var Person = function(name){ this.name = name; this.say = function(){ return "I am " + thi ...

  10. 使用 Fastlane 实现 IOS 持续集成

    简介 持续集成是个“一次配置长期受益”的工作.但很多小公司都没有.以前在做Windows开发配置感觉简单一些,这次配置iOS的,感觉步骤还挺多.整理出来,分享给大家,不正确的地方请及时指正. 本文主要 ...