Class JRendererLabel

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

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

    Note: the painter support will be switched to painter_work as soon it enters main. The reasoning for the performance-overrides is copied from core:

    The standard JLabel component was not designed to be used this way and we want to avoid triggering a revalidate each time the cell is drawn. This would greatly decrease performance because the revalidate message would be passed up the hierarchy of the container to determine whether any other components would be affected. As the renderer is only parented for the lifetime of a painting operation we similarly want to avoid the overhead associated with walking the hierarchy for painting operations. So this class overrides the validate, invalidate, revalidate, repaint, and firePropertyChange methods to be no-ops and override the isOpaque method solely to improve performance. If you write your own renderer component, please keep this performance consideration in mind.

    Author:
    Jeanette Winzenburg
    See Also:
    Serialized Form
    • Field Detail

      • painter

        protected Painter painter
    • Constructor Detail

      • JRendererLabel

        public JRendererLabel()
    • Method Detail

      • isOpaque

        public boolean isOpaque()
        Overridden for performance reasons.

        PENDING: Think about Painters and opaqueness?

        Overrides:
        isOpaque in class JComponent
      • paintComponent

        protected void paintComponent​(Graphics g)

        Overridden to inject Painter's painting.

        TODO: cleanup logic - see JRendererCheckBox.

        Overrides:
        paintComponent in class JComponent
      • paintComponentWithPainter

        protected void paintComponentWithPainter​(Graphics2D g)
        PRE: painter != null, isOpaque()
        Parameters:
        g -
      • 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
      • 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