- java.lang.Object
-
- javax.swing.RepaintManager
-
public class RepaintManager extends Object
此类管理重绘请求,允许最小化重绘次数,例如通过将多个请求折叠为组件树成员的单个重绘。由于1.6
RepaintManager手柄重绘了Swing的顶层组件(请求JApplet,JWindow,JFrame和JDialog)。 任何对其中一个的调用repaint将调用适当的addDirtyRegion方法。- 从以下版本开始:
- 1.2
-
-
构造方法摘要
构造方法 构造器 描述 RepaintManager()创建一个新的RepaintManager实例。
-
方法摘要
所有方法 静态方法 实例方法 具体的方法 弃用的方法 变量和类型 方法 描述 voidaddDirtyRegion(Applet applet, int x, int y, int w, int h)已过时。不推荐使用Applet API。voidaddDirtyRegion(Window window, int x, int y, int w, int h)将window添加到需要重新绘制的Component列表中。voidaddDirtyRegion(JComponent c, int x, int y, int w, int h)在应刷新的组件列表中添加组件。voidaddInvalidComponent(JComponent invalidComponent)将组件标记为需要布局并为事件调度线程排队runnable,该线程将首先验证组件isValidateRoot()祖先。static RepaintManagercurrentManager(Component c)给定Component的调用线程返回RepaintManager。static RepaintManagercurrentManager(JComponent c)给定JComponent,返回RepaintManager以获取调用线程。RectanglegetDirtyRegion(JComponent aComponent)返回组件的当前脏区域。DimensiongetDoubleBufferMaximumSize()返回最大双缓冲区大小。ImagegetOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)返回应该用作组件c的双缓冲区的屏幕外缓冲区。ImagegetVolatileOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)返回一个易失性的屏幕外缓冲区,该缓冲区应该用作具有指定组件的双缓冲区c。booleanisCompletelyDirty(JComponent aComponent)如果 aComponent将在下一个paintDirtyRegions()期间完全绘制,则返回true的便捷方法。booleanisDoubleBufferingEnabled()如果此RepaintManager是双缓冲的,则返回true。voidmarkCompletelyClean(JComponent aComponent)将组件标记为完全清洁。voidmarkCompletelyDirty(JComponent aComponent)将组件标记为完全脏。voidpaintDirtyRegions()绘制所有标记为脏的组件。voidremoveInvalidComponent(JComponent component)从无效组件列表中删除组件。static voidsetCurrentManager(RepaintManager aRepaintManager)设置应该用于调用线程的RepaintManager。voidsetDoubleBufferingEnabled(boolean aFlag)在此RepaintManager中启用或禁用双缓冲。voidsetDoubleBufferMaximumSize(Dimension d)设置最大双缓冲区大小。StringtoString()返回显示和标识此对象属性的字符串。voidvalidateInvalidComponents()验证已标记为无效的所有组件。
-
-
-
方法详细信息
-
currentManager
public static RepaintManager currentManager(Component c)
给定Component的调用线程返回RepaintManager。- 参数
-
c- 一个组件 - 在默认实现中未使用,但可以被重写版本用于返回不同的RepaintManager,具体取决于组件 - 结果
- RepaintManager对象
-
currentManager
public static RepaintManager currentManager(JComponent c)
给定JComponent,返回RepaintManager以获取调用线程。注意:此方法用于与早期版本的Swing库进行向后二进制兼容。 它只返回
currentManager(Component)返回的结果。- 参数
-
c- JComponent - 未使用 - 结果
- RepaintManager对象
-
setCurrentManager
public static void setCurrentManager(RepaintManager aRepaintManager)
设置应该用于调用线程的RepaintManager。 aRepaintManager将成为调用线程的线程组的当前RepaintManager。- 参数
-
aRepaintManager- 要使用的RepaintManager对象
-
addInvalidComponent
public void addInvalidComponent(JComponent invalidComponent)
将组件标记为需要布局并为事件调度线程排队runnable,该线程将首先验证组件isValidateRoot()祖先。- 参数
-
invalidComponent- 一个组件 - 另请参见:
-
JComponent.isValidateRoot(),removeInvalidComponent(javax.swing.JComponent)
-
removeInvalidComponent
public void removeInvalidComponent(JComponent component)
从无效组件列表中删除组件。- 参数
-
component- 一个组件 - 另请参见:
-
addInvalidComponent(javax.swing.JComponent)
-
addDirtyRegion
public void addDirtyRegion(JComponent c, int x, int y, int w, int h)
在应刷新的组件列表中添加组件。 如果c已经有脏区域,则矩形(x,y,w,h)将与应重绘的区域联合。- 参数
-
c- 要重新绘制的组件,null会导致无任何结果。 -
x- 要重绘的区域的X坐标 -
y- 要重新绘制的区域的Y坐标 -
w- 要重新绘制的区域的宽度 -
h- 要重新绘制的区域的高度 - 另请参见:
-
JComponent.repaint(long, int, int, int, int)
-
addDirtyRegion
public void addDirtyRegion(Window window, int x, int y, int w, int h)
将window添加到需要重新绘制的Component列表中。- 参数
-
window- 要重绘的窗口,null会导致任何事情都没有发生。 -
x- 要重新绘制的区域的X坐标 -
y- 要重新绘制的区域的Y坐标 -
w- 要重新绘制的区域的宽度 -
h- 要重新绘制的区域的高度 - 从以下版本开始:
- 1.6
- 另请参见:
-
JFrame.repaint(long, int, int, int, int),JWindow.repaint(long, int, int, int, int),JDialog.repaint(long, int, int, int, int)
-
addDirtyRegion
@Deprecated(since="9") public void addDirtyRegion(Applet applet, int x, int y, int w, int h)
Deprecated.The Applet API is deprecated. See the java.applet package documentation for further information.将applet添加到需要重新绘制的Component列表中。- 参数
-
applet- 重绘的小程序,null导致什么都没发生。 -
x- 要重新绘制的区域的X坐标 -
y- 要重新绘制的区域的Y坐标 -
w- 要重新绘制的区域的宽度 -
h- 要重新绘制的区域的高度 - 从以下版本开始:
- 1.6
- 另请参见:
-
JApplet.repaint(long, int, int, int, int)
-
getDirtyRegion
public Rectangle getDirtyRegion(JComponent aComponent)
返回组件的当前脏区域。 如果组件不脏,则返回一个空矩形。- 参数
-
aComponent- 一个组件 - 结果
- 该区域
-
markCompletelyDirty
public void markCompletelyDirty(JComponent aComponent)
将组件标记为完全脏。 在下一次paintDirtyRegions()调用期间, aComponent将被完全绘制。- 参数
-
aComponent- 一个组件
-
markCompletelyClean
public void markCompletelyClean(JComponent aComponent)
将组件标记为完全清洁。 在下一次paintDirtyRegions()调用期间, aComponent不会被绘制。- 参数
-
aComponent- 一个组件
-
isCompletelyDirty
public boolean isCompletelyDirty(JComponent aComponent)
如果aComponent将在下一个paintDirtyRegions()期间完全绘制,则返回true的便捷方法。 如果计算脏区域对于组件来说是昂贵的,请使用此方法并避免在返回true时计算脏区域。- 参数
-
aComponent- 组件 - 结果
-
true如果 aComponent将在下一个paintDirtyRegions()期间完全绘制。
-
validateInvalidComponents
public void validateInvalidComponents()
验证已标记为无效的所有组件。
-
paintDirtyRegions
public void paintDirtyRegions()
绘制所有标记为脏的组件。
-
getOffscreenBuffer
public Image getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
返回应该用作组件c的双缓冲区的屏幕外缓冲区。 默认情况下,每个RepaintManager都有一个双缓冲区。 缓冲区可能小于(proposedWidth,proposedHeight)这是在为接收重绘管理器设置的最大双缓冲区大小时发生的。- 参数
-
c- 组件 -
proposedWidth- 缓冲区的宽度 -
proposedHeight- 缓冲区的高度 - 结果
- 图片
-
getVolatileOffscreenBuffer
public Image getVolatileOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
返回一个易失性的屏幕外缓冲区,该缓冲区应该用作具有指定组件c的双缓冲区。 返回的图像将是VolatileImage的实例,如果无法实例化VolatileImage对象,则返回null。 此缓冲区可能小于(proposedWidth,proposedHeight)。 当为此重绘管理器设置了最大双缓冲区大小时,会发生这种情况。- 参数
-
c- 组件 -
proposedWidth- 缓冲区的宽度 -
proposedHeight- 缓冲区的高度 - 结果
- 不稳定的形象
- 从以下版本开始:
- 1.4
- 另请参见:
-
VolatileImage
-
setDoubleBufferMaximumSize
public void setDoubleBufferMaximumSize(Dimension d)
设置最大双缓冲区大小。- 参数
-
d- 维度
-
getDoubleBufferMaximumSize
public Dimension getDoubleBufferMaximumSize()
返回最大双缓冲区大小。- 结果
- 表示最大大小的Dimension对象
-
setDoubleBufferingEnabled
public void setDoubleBufferingEnabled(boolean aFlag)
在此RepaintManager中启用或禁用双缓冲。 注意:此属性的默认值设置为在给定平台上获得最佳绘制性能,并且不建议程序直接修改此属性。- 参数
-
aFlag- 如果激活双缓冲,aFlagtrue - 另请参见:
-
isDoubleBufferingEnabled()
-
isDoubleBufferingEnabled
public boolean isDoubleBufferingEnabled()
如果此RepaintManager是双缓冲的,则返回true。 此属性的默认值可能因平台而异。 在AWT中支持本机双缓冲的平台上,默认值为false以避免在Swing中进行不必要的缓冲。 在不支持本机双缓冲的平台上,默认值为true。- 结果
- 如果此对象是双缓冲的,则为true
-
-