Class TransparentComponentWrapper

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.jidesoft.swing.TransparentComponentWrapper
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class TransparentComponentWrapper extends JComponent
This is a wrapper component for containing another component that uses a transparent (or translucent background).

This class is a solution to a problem that may be encountered in Swing when using transparency in the background of a component. The problem is that when you want to use a background colour with transparency, you need to set the opaque property of the component to be false to force the opaque parent components to be painted first. The catch is that if the opaque property is set to false, the component's background may not be painted at all - so you lose the transparency effect you wanted to achieve.

A component that uses a transparent background can be wrapped by this class, which has opaque set to false (to ensure that the opaque parents are painted first) and also takes on the responsibility of painting the background of the wrapped component.

See Also:
  • Constructor Details

    • TransparentComponentWrapper

      public TransparentComponentWrapper(JComponent delegate)
  • Method Details

    • paintComponent

      public void paintComponent(Graphics g)
      Paints the background of this component using the background colour of the delegate
      Overrides:
      paintComponent in class JComponent