class JXPanel extends JPanel implements AlphaPaintable, BackgroundPaintable, Scrollable {

    @Override
    public void setAlpha(float alpha) {
        if (isPatch()) {
            setAlphaPatch(alpha);
            return;
        }
        if (alpha < 0f || alpha > 1f) {
            throw new IllegalArgumentException("invalid alpha value " + alpha);
        }
        
        float oldValue = getAlpha();
        this.alpha = alpha;
        
        if (getAlpha() < 1f) {
            if (oldValue == 1) {
                //it used to be 1, but now is not. Save the oldOpaque
                oldOpaque = isOpaque();
                super.setOpaque(false);
            }
            
            installRepaintManager();
        } else {
            uninstallRepaintManager();
            
            //restore the oldOpaque if it was true (since opaque is false now)
            if (oldOpaque) {
                super.setOpaque(true);
            }
        }
        
        firePropertyChange("alpha", oldValue, getAlpha());
        repaint();
    }

}

class JXPanelTest extends JPanel {

    @SuppressWarnings("unused")
    private static final Logger LOG;

    @Test(expected = IllegalArgumentException.class)
    public void testSetAlphaWithLessThanZero() {

        new JXPanel().setAlpha(Math.nextAfter(0f, Float.NEGATIVE_INFINITY));
    }

}