Class ComponentPaintCache

java.lang.Object
games.stendhal.client.gui.ComponentPaintCache

public class ComponentPaintCache extends Object
Cached painting for components that need it. Components using this need to implement the Cacheable interface, and override the paint method to something like:
 public void paint(Graphics g) {
        cache.paintComponent(g);
        paintChildren(g);
 } 
Also, the components need to call cache.invalidate() should the component need a proper redraw. Size changes are automatically handled.
  • Constructor Details

    • ComponentPaintCache

      public ComponentPaintCache(ComponentPaintCache.Cacheable component)
      Create a new paint cache.
      Parameters:
      component - the cached component
  • Method Details

    • paintComponent

      public void paintComponent(Graphics g)
      Paint the cached component.
      Parameters:
      g - graphics
    • setPaintChildren

      public void setPaintChildren(boolean paint)
      Set if the child components should be cached as images as well. The default is not caching. Do change it to true unless the children are static images or you take care of calling invalidate() when they change.
      Parameters:
      paint - true if the child components should be included in the cached image, false otherwise