Class DrawnButton

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public class DrawnButton extends JButton
A JButton whose visible content is drawn by a ButtonPainter.

This button is useful for toolbar, palette, and dashboard controls whose icons are easier to express as vector drawing code than as image resources. The button can be static or animated. Animated buttons are repainted by DrawnComponentManager while they are displayable.

See Also:
  • Constructor Details

    • DrawnButton

      public DrawnButton(boolean animated, ButtonPainter painter)
      Creates a drawn push button.
      Parameters:
      animated - true to repaint this button on the shared animation timer
      painter - the painter used to draw the button contents; may be null
    • DrawnButton

      public DrawnButton(ButtonPainter painter)
      Creates a drawn push button that is not animated.
      Parameters:
      painter - the painter used to draw the button contents; may be null
  • Method Details

    • getPainter

      public ButtonPainter getPainter()
      Returns the current button painter.
      Returns:
      the current painter, or null
    • setPainter

      public void setPainter(ButtonPainter painter)
      Sets the painter used to draw this button.
      Parameters:
      painter - the new painter, or null for no custom drawing
    • isAnimated

      public boolean isAnimated()
      Returns whether this button uses the shared animation timer.
      Returns:
      true if animated
    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class JComponent
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class JButton
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • paintComponent

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