Class ShapedPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, BackgroundPainter
Direct Known Subclasses:
HoverableShapedPanel

public class ShapedPanel extends BaseContainer implements BackgroundPainter

A panel that has support for a ComponentPainter and a ShapedBorder. The background of the panel is painted as normal and then the ComponentPainter paints the area inside the ShapedBorder or the complete component area if the its border isn't a ShapedBorder.

If a ShapedBorder is applied to this panel, mouse events etc. are only triggered for this panel if the point is inside the Shape of the ShapedBorder. Child components of this panel can optionally be clipped using the Shape.

A ShapedBorder wrapped inside CompoundBorder's will be used by the ShapedPanel, but a ShapedBorder wrapped inside other border types can't be found and is hence not used by the panel.

See Also:
  • Constructor Details

  • Method Details

    • getShape

      public Shape getShape()
    • getComponentPainter

      public ComponentPainter getComponentPainter()
      Description copied from interface: BackgroundPainter
      Returns the ComponentPainter that is used to paint the background of this object.
      Specified by:
      getComponentPainter in interface BackgroundPainter
      Returns:
      the ComponentPainter that is used to paint the background of this object, null if there is none
    • setComponentPainter

      public void setComponentPainter(ComponentPainter painter)
    • getDirection

      public Direction getDirection()
    • isHorizontalFlip

      public boolean isHorizontalFlip()
    • setHorizontalFlip

      public void setHorizontalFlip(boolean horizontalFlip)
    • isVerticalFlip

      public boolean isVerticalFlip()
    • setVerticalFlip

      public void setVerticalFlip(boolean verticalFlip)
    • setDirection

      public void setDirection(Direction direction)
    • isClipChildren

      public boolean isClipChildren()
    • setClipChildren

      public void setClipChildren(boolean clipChildren)
    • getShapedBorder

      public ShapedBorder getShapedBorder()
    • setBorder

      public void setBorder(Border border)
      Overrides:
      setBorder in class JComponent
    • paintChildren

      protected void paintChildren(Graphics g)
      Overrides:
      paintChildren in class JComponent
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class BaseContainer
    • contains

      public boolean contains(int x, int y)
      Overrides:
      contains in class JComponent
    • inside

      public boolean inside(int x, int y)
      Overrides:
      inside in class Component