Class CompositeIcon

  • All Implemented Interfaces:
    javax.swing.Icon, javax.swing.SwingConstants

    public class CompositeIcon
    extends java.lang.Object
    implements javax.swing.Icon, javax.swing.SwingConstants
    CompositeIcon is an Icon implementation which draws two icons with a specified relative position.

    LEFT, RIGHT, TOP, BOTTOM specify how icon1 is drawn relative to icon2

    CENTER: icon1 is drawn first, icon2 is drawn over it and with horizontal and vertical orientations within the alloted space

    It's useful with VTextIcon when you want an icon with your text: if icon1 is the graphic icon and icon2 is the VTextIcon, you get a similar effect to a JLabel with a graphic icon and text

    See Also:
    http://www.macdevcenter.com/pub/a/mac/2002/03/22/vertical_text.html
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int fHorizontalOrientation  
      (package private) javax.swing.Icon fIcon1  
      (package private) javax.swing.Icon fIcon2  
      (package private) int fPosition  
      (package private) int fVerticalOrientation  
      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      CompositeIcon​(javax.swing.Icon icon1, javax.swing.Icon icon2)
      Create a CompositeIcon from the specified Icons, using the default relative position (icon1 above icon2) and orientations (centered horizontally and vertically)
      CompositeIcon​(javax.swing.Icon icon1, javax.swing.Icon icon2, int position)
      Create a CompositeIcon from the specified Icons, using the specified relative position and default orientations (centered horizontally and vertically)
      CompositeIcon​(javax.swing.Icon icon1, javax.swing.Icon icon2, int position, int horizontalOrientation, int verticalOrientation)
      Create a CompositeIcon from the specified Icons, using the specified relative position and orientations
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getIconHeight()
      Returns the icon's height.
      int getIconWidth()
      Returns the icon's width.
      void paintIcon​(java.awt.Component c, java.awt.Graphics g, int x, int y)
      Draw the icon at the specified location.
      (package private) void paintIcon​(java.awt.Component c, java.awt.Graphics g, javax.swing.Icon icon, int x, int y, int width, int height, int horizontalOrientation, int verticalOrientation)
      Paints one icon in the specified rectangle with the given orientations
      • Methods inherited from class java.lang.Object

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

      • CompositeIcon

        public CompositeIcon​(javax.swing.Icon icon1,
                             javax.swing.Icon icon2)
        Create a CompositeIcon from the specified Icons, using the default relative position (icon1 above icon2) and orientations (centered horizontally and vertically)
      • CompositeIcon

        public CompositeIcon​(javax.swing.Icon icon1,
                             javax.swing.Icon icon2,
                             int position)
        Create a CompositeIcon from the specified Icons, using the specified relative position and default orientations (centered horizontally and vertically)
      • CompositeIcon

        public CompositeIcon​(javax.swing.Icon icon1,
                             javax.swing.Icon icon2,
                             int position,
                             int horizontalOrientation,
                             int verticalOrientation)
        Create a CompositeIcon from the specified Icons, using the specified relative position and orientations
    • Method Detail

      • paintIcon

        public void paintIcon​(java.awt.Component c,
                              java.awt.Graphics g,
                              int x,
                              int y)
        Draw the icon at the specified location. Icon implementations may use the Component argument to get properties useful for painting, e.g. the foreground or background color.
        Specified by:
        paintIcon in interface javax.swing.Icon
      • paintIcon

        void paintIcon​(java.awt.Component c,
                       java.awt.Graphics g,
                       javax.swing.Icon icon,
                       int x,
                       int y,
                       int width,
                       int height,
                       int horizontalOrientation,
                       int verticalOrientation)
        Paints one icon in the specified rectangle with the given orientations
      • getIconWidth

        public int getIconWidth()
        Returns the icon's width.
        Specified by:
        getIconWidth in interface javax.swing.Icon
        Returns:
        an int specifying the fixed width of the icon.
      • getIconHeight

        public int getIconHeight()
        Returns the icon's height.
        Specified by:
        getIconHeight in interface javax.swing.Icon
        Returns:
        an int specifying the fixed height of the icon.