Interface Overlayable

  • All Superinterfaces:
    javax.swing.SwingConstants
    All Known Implementing Classes:
    DefaultOverlayable

    public interface Overlayable
    extends javax.swing.SwingConstants
    Overlayable provides a way to add a number of components on top of another component as the overlay components. Usually we make a component implementing Overlayable interface although it is not required. This interface will allow user to add/remove other components as overlay components and set their location independently.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CLIENT_PROPERTY_OVERLAYABLE
      Client property.
      • Fields inherited from interface javax.swing.SwingConstants

        BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addOverlayComponent​(javax.swing.JComponent component)
      Adds an overlay component to the center.
      void addOverlayComponent​(javax.swing.JComponent component, int location)
      Adds an overlay component at the specified location.
      void addOverlayComponent​(javax.swing.JComponent component, int location, int index)
      Adds an overlay component at the specified location.
      javax.swing.JComponent[] getOverlayComponents()
      Gets the overlay component.
      int getOverlayLocation​(javax.swing.JComponent component)
      Gets the overlay component location.
      java.awt.Insets getOverlayLocationInsets()
      Gets the insets of the overlay component relative to the border of the component.
      void removeOverlayComponent​(javax.swing.JComponent component)
      Removes an overlay component that was added before.
      void setOverlayLocation​(javax.swing.JComponent component, int location)
      Sets the overlay component location.
      void setOverlayLocationInsets​(java.awt.Insets insets)
      Sets the insets of the overlay component relative to the border of the component.
      void setOverlayVisible​(boolean visible)
      Sets all the overlay components visible or invisible.
    • Field Detail

      • CLIENT_PROPERTY_OVERLAYABLE

        static final java.lang.String CLIENT_PROPERTY_OVERLAYABLE
        Client property. If a component has this property, the property will be an Overlayable. The component is the actual component of the Overlayable.
        See Also:
        Constant Field Values
    • Method Detail

      • addOverlayComponent

        void addOverlayComponent​(javax.swing.JComponent component)
        Adds an overlay component to the center.
        Parameters:
        component - the overlay component.
      • addOverlayComponent

        void addOverlayComponent​(javax.swing.JComponent component,
                                 int location)
        Adds an overlay component at the specified location. The location could be one of the following values.
        • SwingConstants.CENTER
        • SwingConstants.SOUTH
        • SwingConstants.NORTH
        • SwingConstants.WEST
        • SwingConstants.EAST
        • SwingConstants.NORTH_EAST
        • SwingConstants.NORTH_WEST
        • SwingConstants.SOUTH_EAST
        • SwingConstants.SOUTH_WEST
        Parameters:
        component - the overlay component.
        location - the overlay location.
      • addOverlayComponent

        void addOverlayComponent​(javax.swing.JComponent component,
                                 int location,
                                 int index)
        Adds an overlay component at the specified location. The location could be one of the following values.
        • SwingConstants.CENTER
        • SwingConstants.SOUTH
        • SwingConstants.NORTH
        • SwingConstants.WEST
        • SwingConstants.EAST
        • SwingConstants.NORTH_EAST
        • SwingConstants.NORTH_WEST
        • SwingConstants.SOUTH_EAST
        • SwingConstants.SOUTH_WEST
        Parameters:
        component - the overlay component.
        location - the overlay location.
        index - the overlay index. 0 means the first overlay component. -1 means the last overlay component.
      • removeOverlayComponent

        void removeOverlayComponent​(javax.swing.JComponent component)
        Removes an overlay component that was added before.
        Parameters:
        component -
      • getOverlayComponents

        javax.swing.JComponent[] getOverlayComponents()
        Gets the overlay component.
        Returns:
        the overlay component.
      • setOverlayLocation

        void setOverlayLocation​(javax.swing.JComponent component,
                                int location)
        Sets the overlay component location. The valid values are defined in SwingConstants. They are
        • SwingConstants.CENTER
        • SwingConstants.SOUTH
        • SwingConstants.NORTH
        • SwingConstants.WEST
        • SwingConstants.EAST
        • SwingConstants.NORTH_EAST
        • SwingConstants.NORTH_WEST
        • SwingConstants.SOUTH_EAST
        • SwingConstants.SOUTH_WEST
        Parameters:
        location - the overlay component location.
      • getOverlayLocation

        int getOverlayLocation​(javax.swing.JComponent component)
        Gets the overlay component location. If -1, it means the component doesn't exit.
        Returns:
        the overlay component location.
      • getOverlayLocationInsets

        java.awt.Insets getOverlayLocationInsets()
        Gets the insets of the overlay component relative to the border of the component. This will affect the actual location of the overlay component except CENTER. If an edge of the insets is greater than 0, it will move the overlay component outwards on that edge. On the opposite, if the value is negative, it will move inward.
        Returns:
        the insets of the overlay component relative to the border of the component.
      • setOverlayLocationInsets

        void setOverlayLocationInsets​(java.awt.Insets insets)
        Sets the insets of the overlay component relative to the border of the component.
        Parameters:
        insets - the insets of the overlay component relative to the border of the component.
      • setOverlayVisible

        void setOverlayVisible​(boolean visible)
        Sets all the overlay components visible or invisible. If you want to set one overlay component visible/invisible, you just need to call setVisible of that component.
        Parameters:
        visible - true to set it visible. False to invisible.