java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.pushingpixels.radiance.theming.extras.internal.contrib.blogofbug.swing.components.GradientPanel
All Implemented Interfaces:
ComponentListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
JCarosel, JCarouselMenu

public class GradientPanel extends JPanel implements ComponentListener
Container that draws (in an optimized way) a gradient in the background
See Also:
  • Field Details

    • start

      protected Color start
      Gradient start colour
    • end

      protected Color end
      Gradient end color
    • gp

      protected GradientPaint gp
      Gradient painter
    • cache

      protected BufferedImage cache
      A pre-rendered gradient in an image
  • Constructor Details

    • GradientPanel

      public GradientPanel()
  • Method Details

    • setBackground

      public void setBackground(Color color)
      Set the background to a single color
      Overrides:
      setBackground in class JComponent
      Parameters:
      color - The color for a solid background
    • setBackground

      public void setBackground(Color start, Color end)
      Sets two background colors for a gradient
      Parameters:
      start - Top (first) color
      end - Bottom (final) color
    • paintComponent

      public void paintComponent(Graphics graphics)
      paints the gradient.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      graphics - The graphics context
    • makeGradient

      private void makeGradient()
      Pre-renders the gradient
    • componentResized

      public void componentResized(ComponentEvent componentEvent)
      Recalculates the gradient when it's resized
      Specified by:
      componentResized in interface ComponentListener
      Parameters:
      componentEvent - The event object
    • componentShown

      public void componentShown(ComponentEvent componentEvent)
      Ignored
      Specified by:
      componentShown in interface ComponentListener
      Parameters:
      componentEvent - The component event
    • componentMoved

      public void componentMoved(ComponentEvent componentEvent)
      Not used *
      Specified by:
      componentMoved in interface ComponentListener
      Parameters:
      componentEvent - The event
    • componentHidden

      public void componentHidden(ComponentEvent componentEvent)
      Not used *
      Specified by:
      componentHidden in interface ComponentListener
      Parameters:
      componentEvent - The event