Interface ButtonPainter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ButtonPainter
Paints the vector contents of a DrawnButton or DrawnToggleButton.

A painter is deliberately independent of image files. It is given the target button, the drawable bounds inside the button's insets, and an animation frame value. The same painter instance may be shared by many buttons, so implementations should not store per-button mutable drawing state unless they do so carefully.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Dimension
    The default drawing canvas used when no explicit size is supplied.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw(Graphics2D g2, AbstractButton button, Rectangle bounds, long frameCount)
    Draws the button contents.
    default Dimension
    Returns the natural canvas size for buttons using this painter.
  • Field Details

    • DEFAULT_PREFERRED_SIZE

      static final Dimension DEFAULT_PREFERRED_SIZE
      The default drawing canvas used when no explicit size is supplied.
  • Method Details

    • draw

      void draw(Graphics2D g2, AbstractButton button, Rectangle bounds, long frameCount)
      Draws the button contents.
      Parameters:
      g2 - the graphics context; the caller owns and disposes this copy
      button - the button being painted
      bounds - the drawable area inside the button insets
      frameCount - the current animation frame, or 0 for non-animated buttons
    • getPreferredSize

      default Dimension getPreferredSize()
      Returns the natural canvas size for buttons using this painter.

      Override this for non-square or detailed drawings. The returned dimension is copied by the button, so callers may safely return a shared constant.

      Returns:
      the preferred drawing size