Class OverlayableUtils


  • public class OverlayableUtils
    extends java.lang.Object
    This util class has several methods related to Overlayable.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Overlayable[] getAllOverlayables​(javax.swing.JComponent component)
      Gets all overlayables associated with this component and its parents.
      static Overlayable getOverlayable​(javax.swing.JComponent component)
      Gets the overlayable associated with this component and its parents.
      static javax.swing.Icon getPredefinedOverlayIcon​(java.lang.String name)
      Gets the predefined icon that can be used as the overlay icon for the Swing component.
      static void repaintAllOverlayables​(javax.swing.JComponent component)
      Repaints all the overlayables associated with the component or its parents.
      static void repaintOverlayable​(javax.swing.JComponent component)
      Repaints the overlayable component associated with component.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OverlayableUtils

        public OverlayableUtils()
    • Method Detail

      • getOverlayable

        public static Overlayable getOverlayable​(javax.swing.JComponent component)
        Gets the overlayable associated with this component and its parents. This method will find the first overlayable that contains the component or its parents.
        Parameters:
        component - the component.
        Returns:
        the overlayable.
      • getAllOverlayables

        public static Overlayable[] getAllOverlayables​(javax.swing.JComponent component)
        Gets all overlayables associated with this component and its parents. Different from getOverlayable(javax.swing.JComponent), this method will find the all overlayables that contain the component or its parents.
        Parameters:
        component - the component
        Returns:
        all the overlayables.
      • repaintOverlayable

        public static void repaintOverlayable​(javax.swing.JComponent component)
        Repaints the overlayable component associated with component. Because the overlay component is shown above the component and its child components, if any of the components repaint, the overlay component will be covered if the overlay component doesn't know to repaint immediately. Due to way Swing repaintManager works, there isn't any other better way to solve the issue other than the component has code to trigger the repaint of the overlay component. That's one reason we provide this way to repaint the overlay component easily.

        See below for an example of how to prepare the component to be ready for the overlayable.

        
         public OverlayTextField() {
         ...
         public void repaint(long tm, int x, int y, int width, int height) {
             super.repaint(tm, x, y, width, height);
             OverlayableUtils.repaintOverlayable(this);
         }
         
        Parameters:
        component - the component that has an overlayable.
      • repaintAllOverlayables

        public static void repaintAllOverlayables​(javax.swing.JComponent component)
        Repaints all the overlayables associated with the component or its parents.
        Parameters:
        component - the component.