Class DrawnToggleButton

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

public class DrawnToggleButton extends JToggleButton
A JToggleButton whose visible content is drawn by a ButtonPainter.

The selected, rollover, pressed, and enabled states remain available through the normal Swing button model. A painter can query those states from the supplied button and render them however it chooses.

See Also:
  • Constructor Details

    • DrawnToggleButton

      public DrawnToggleButton(boolean animated, ButtonPainter painter)
      Creates a drawn toggle 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
    • DrawnToggleButton

      public DrawnToggleButton(ButtonPainter painter)
      Creates a drawn toggle 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 AbstractButton
    • getPreferredSize

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

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