Class RepaintManager
public class RepaintManager extends Object
As of 1.6 RepaintManager
handles repaint requests for Swing's top level components (JApplet
, JWindow
, JFrame
and JDialog
). Any calls to repaint
on one of these will call into the appropriate addDirtyRegion
method.
- Since:
- 1.2
Constructor Summary
Constructor | Description |
---|---|
RepaintManager() |
Create a new RepaintManager instance. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void |
addDirtyRegion |
Deprecated, for removal: This API element is subject to removal in a future version. The Applet API is deprecated. |
void |
addDirtyRegion |
Adds window to the list of Component s that need to be repainted. |
void |
addDirtyRegion |
Add a component in the list of components that should be refreshed. |
void |
addInvalidComponent |
Mark the component as in need of layout and queue a runnable for the event dispatching thread that will validate the components first isValidateRoot() ancestor. |
static RepaintManager |
currentManager |
Return the RepaintManager for the calling thread given a Component. |
static RepaintManager |
currentManager |
Return the RepaintManager for the calling thread given a JComponent. |
Rectangle |
getDirtyRegion |
Return the current dirty region for a component. |
Dimension |
getDoubleBufferMaximumSize() |
Returns the maximum double buffer size. |
Image |
getOffscreenBuffer |
Return the offscreen buffer that should be used as a double buffer with the component c . |
Image |
getVolatileOffscreenBuffer |
Return a volatile offscreen buffer that should be used as a double buffer with the specified component c . |
boolean |
isCompletelyDirty |
Convenience method that returns true if aComponent will be completely painted during the next paintDirtyRegions(). |
boolean |
isDoubleBufferingEnabled() |
Returns true if this RepaintManager is double buffered. |
void |
markCompletelyClean |
Mark a component completely clean. |
void |
markCompletelyDirty |
Mark a component completely dirty. |
void |
paintDirtyRegions() |
Paint all of the components that have been marked dirty. |
void |
removeInvalidComponent |
Remove a component from the list of invalid components. |
static void |
setCurrentManager |
Set the RepaintManager that should be used for the calling thread. |
void |
setDoubleBufferingEnabled |
Enables or disables double buffering in this RepaintManager. |
void |
setDoubleBufferMaximumSize |
Set the maximum double buffer size. |
String |
toString() |
Returns a string that displays and identifies this object's properties. |
void |
validateInvalidComponents() |
Validate all of the components that have been marked invalid. |
Constructor Details
RepaintManager
public RepaintManager()
Method Details
currentManager
public static RepaintManager currentManager(Component c)
- Parameters:
-
c
- a Component -- unused in the default implementation, but could be used by an overridden version to return a different RepaintManager depending on the Component - Returns:
- the RepaintManager object
currentManager
public static RepaintManager currentManager(JComponent c)
Note: This method exists for backward binary compatibility with earlier versions of the Swing library. It simply returns the result returned by currentManager(Component)
.
- Parameters:
-
c
- a JComponent -- unused - Returns:
- the RepaintManager object
setCurrentManager
public static void setCurrentManager(RepaintManager aRepaintManager)
- Parameters:
-
aRepaintManager
- the RepaintManager object to use
addInvalidComponent
public void addInvalidComponent(JComponent invalidComponent)
- Parameters:
-
invalidComponent
- a component - See Also:
removeInvalidComponent
public void removeInvalidComponent(JComponent component)
- Parameters:
-
component
- a component - See Also:
addDirtyRegion
public void addDirtyRegion(JComponent c, int x, int y, int w, int h)
- Parameters:
-
c
- Component to repaint, null results in nothing happening. -
x
- X coordinate of the region to repaint -
y
- Y coordinate of the region to repaint -
w
- Width of the region to repaint -
h
- Height of the region to repaint - See Also:
addDirtyRegion
public void addDirtyRegion(Window window, int x, int y, int w, int h)
window
to the list of Component
s that need to be repainted.- Parameters:
-
window
- Window to repaint, null results in nothing happening. -
x
- X coordinate of the region to repaint -
y
- Y coordinate of the region to repaint -
w
- Width of the region to repaint -
h
- Height of the region to repaint - Since:
- 1.6
- See Also:
addDirtyRegion
@Deprecated(since="9", forRemoval=true) public void addDirtyRegion(Applet applet, int x, int y, int w, int h)
applet
to the list of Component
s that need to be repainted.- Parameters:
-
applet
- Applet to repaint, null results in nothing happening. -
x
- X coordinate of the region to repaint -
y
- Y coordinate of the region to repaint -
w
- Width of the region to repaint -
h
- Height of the region to repaint - Since:
- 1.6
- See Also:
getDirtyRegion
public Rectangle getDirtyRegion(JComponent aComponent)
- Parameters:
-
aComponent
- a component - Returns:
- the region
markCompletelyDirty
public void markCompletelyDirty(JComponent aComponent)
- Parameters:
-
aComponent
- a component
markCompletelyClean
public void markCompletelyClean(JComponent aComponent)
- Parameters:
-
aComponent
- a component
isCompletelyDirty
public boolean isCompletelyDirty(JComponent aComponent)
- Parameters:
-
aComponent
- a component - Returns:
-
true
if aComponent will be completely painted during the next paintDirtyRegions().
validateInvalidComponents
public void validateInvalidComponents()
paintDirtyRegions
public void paintDirtyRegions()
toString
public String toString()
getOffscreenBuffer
public Image getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
c
. By default there is a double buffer per RepaintManager. The buffer might be smaller than (proposedWidth,proposedHeight)
This happens when the maximum double buffer size as been set for the receiving repaint manager.- Parameters:
-
c
- the component -
proposedWidth
- the width of the buffer -
proposedHeight
- the height of the buffer - Returns:
- the image
getVolatileOffscreenBuffer
public Image getVolatileOffscreenBuffer(Component c, int proposedWidth, int proposedHeight)
c
. The image returned will be an instance of VolatileImage, or null if a VolatileImage object could not be instantiated. This buffer might be smaller than (proposedWidth,proposedHeight)
. This happens when the maximum double buffer size has been set for this repaint manager.- Parameters:
-
c
- the component -
proposedWidth
- the width of the buffer -
proposedHeight
- the height of the buffer - Returns:
- the volatile image
- Since:
- 1.4
- See Also:
setDoubleBufferMaximumSize
public void setDoubleBufferMaximumSize(Dimension d)
- Parameters:
-
d
- the dimension
getDoubleBufferMaximumSize
public Dimension getDoubleBufferMaximumSize()
- Returns:
- a Dimension object representing the maximum size
setDoubleBufferingEnabled
public void setDoubleBufferingEnabled(boolean aFlag)
- Parameters:
-
aFlag
- true to activate double buffering - See Also:
isDoubleBufferingEnabled
public boolean isDoubleBufferingEnabled()
false
to avoid unnecessary buffering in Swing. On platforms where native double buffering is not supported, the default value will be true
.- Returns:
- true if this object is double buffered
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/RepaintManager.html