Class JRendererCheckBox

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

public class JRendererCheckBox extends JCheckBox implements PainterAware
A JCheckBox optimized for usage in renderers and with a minimal background painter support.

Note: As of revision #4223, there's a complete overhaul (aka: changed the tricksery) to fix Issue swingx-1513 (allow client code to set renderer transparent) while keeping fix Issue swingx-897 (striping/background lost when painter installed)

Note: The change of logic _did_ introduce a regression (swingx-1546) which was fixed by forcing the box's opacity to true (for regression release 1.6.5-1). Further improvements (like f.i. the option to delegate to the ui's update - to allow LAF installed painters - instead of paint) are deferred to a later normal release, more discussions needed.

Author:
Jeanette Winzenburg
See Also:
  • Field Details

    • painter

      protected Painter painter
      the swingx painter
  • Constructor Details

    • JRendererCheckBox

      public JRendererCheckBox()
      Instantiates a JRendererCheckBox with opacity true.
  • Method Details

    • getPainter

      public Painter getPainter()
      Specified by:
      getPainter in interface PainterAware
      Returns:
      Painter
    • setPainter

      public void setPainter(Painter painter)
      TODO maven-javadoc-plugin 3.3.2 needs a doc here
      Specified by:
      setPainter in interface PainterAware
      Parameters:
      painter - Painter
    • isOpaque

      public boolean isOpaque()

      Overridden to return false if painting flag is true.

      Overrides:
      isOpaque in class JComponent
    • isContentAreaFilled

      public boolean isContentAreaFilled()

      Overridden to return false if painting flag is true.

      Overrides:
      isContentAreaFilled in class AbstractButton
    • setToolTipText

      public void setToolTipText(String text)

      Overridden to not automatically de/register itself from/to the ToolTipManager. As rendering component it is not considered to be active in any way, so the manager must not listen.

      Overrides:
      setToolTipText in class JComponent
    • paintComponent

      protected void paintComponent(Graphics g)
      Overridden to snatch painting from super if a painter installed or Nimbus detected.

      The overall logic currently (since 1.6.5) is to simply call super without SwingX painter. Otherwise, that is with SwingX painter:

      1. if opaque
      1. set a flag which fakes transparency, that is both contentAreaFilled and opaque return false
      2. fill background with the component's background color
      3. apply swingx painter
      4. hook into ui.paint(...)
      5. reset the flag
      1. else
      2. apply swingx painter
      3. call super
      Note that Nimbus is special cased (mainly due to its bug of even row striping instead of odd) and handled as if a SwingX painter were set.
      Overrides:
      paintComponent in class JComponent
    • paintComponentWithPainter

      protected void paintComponentWithPainter(Graphics2D g)
      Parameters:
      g - Graphics2D
    • invalidate

      public void invalidate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      invalidate in class Container
      Since:
      1.5
    • validate

      public void validate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      validate in class Container
    • revalidate

      public void revalidate()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      revalidate in class JComponent
    • repaint

      public void repaint(long tm, int x, int y, int width, int height)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      repaint in class JComponent
    • repaint

      public void repaint(Rectangle r)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      repaint in class JComponent
    • repaint

      public void repaint()
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      repaint in class Component
      Since:
      1.5
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class Component
    • firePropertyChange

      public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
      Overridden for performance reasons. See the Implementation Note for more information.
      Overrides:
      firePropertyChange in class JComponent