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. ubuntu将命令写在一个文件里,执行文件,source命令

    source命令也称为“点命令”,也就是一个点符号(.).source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录.用法: source filename 或 . fil ...

  2. USACO1.1Broken Necklace[环状DP作死]

    题目描述 你有一条由N个红色的,白色的,或蓝色的珠子组成的项链(3<=N<=350),珠子是随意安排的. 这里是 n=29 的二个例子: 第一和第二个珠子在图片中已经被作记号. 图片 A ...

  3. AC日记——潜伏着 openjudge 1.7 11

    11:潜伏者 总时间限制:  1000ms 内存限制:  65536kB 描述 R国和S国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动. 历经艰险后,潜伏于S国的R国间谍小C终于摸清了S国军 ...

  4. wamp5设置外网访问方法

    1.安装完Wamp5之后,从外网访问网页时存在无法访问问题. 2.phpmyadmin外网没法访问 1.解决办法: 打开wamp的托盘图标(右下角),找到"Config files" ...

  5. 在嵌入式开发板中运行程序提示-/bin/sh: ./xx: not found的解决办法

    今天拿着我的tiny6410板子,在虚拟机上用 $arm-linux-gcc he.c -o he 编译后放到tiny6410的文件系统中提示 -/bin/sh: ./xx: not found 后来 ...

  6. [No000007]搜索引擎以图搜图的原理

    之前,Google把"相似图片搜索"正式放上了首页. 你可以用一张图片,搜索互联网上所有与它相似的图片.点击搜索框中照相机的图标. 一个对话框会出现. 你输入网片的网址,或者直接上 ...

  7. java 27 - 8 反射之 通过反射来设置某个对象的某个属性为指定值

    标题的意思是: 通过反射写一个类,类中有个方法.该方法可以设置某个类中的某个属性(构造方法,成员变量,成员方法)为特定的值 代码: // 该方法的参数列表是一个类的 类名.成员变量.给变量的赋值 pu ...

  8. android 下载文件

    import com.example.android.R; import android.app.Activity;import android.os.Bundle;import android.os ...

  9. Android RecyclerView 动画展开item显示详情

    stackoverflow上看到这个问题,答主给了个demo http://stackoverflow.com/questions/27446051/recyclerview-animate-item ...

  10. 在把webpack作为本地开发依赖安装的时候报错

    在把webpack作为本地开发依赖安装的时候报错 Refusing to install webpack as a dependency of itself 原因是package.json里的name ...