JXPanel extends JPanel implements AlphaPaintable, BackgroundPaintable, Scrollable { @Override public void setBackgroundPainter(Painter p) { Painter old = getBackgroundPainter(); if (old instanceof AbstractPainter) { ((AbstractPainter<?>) old).removePropertyChangeListener(painterChangeListener); } backgroundPainter = p; if (backgroundPainter instanceof AbstractPainter) { ((AbstractPainter<?>) backgroundPainter).addPropertyChangeListener(getPainterChangeListener()); } firePropertyChange("backgroundPainter", old, getBackgroundPainter()); repaint(); } JXPanel();  JXPanel(boolean isDoubleBuffered);  JXPanel(LayoutManager layout);  JXPanel(LayoutManager layout, boolean isDoubleBuffered); @Override void setOpaque(boolean opaque); @Override boolean isOpaque(); @Override float getAlpha(); @Override void setAlpha(float alpha); @Override float getEffectiveAlpha(); @Override boolean isInheritAlpha(); @Override void setInheritAlpha(boolean val); final void setScrollableWidthHint(ScrollableSizeHint hint); final void setScrollableHeightHint(ScrollableSizeHint hint); @Override boolean getScrollableTracksViewportHeight(); @Override boolean getScrollableTracksViewportWidth(); @Override Dimension getPreferredScrollableViewportSize(); @Override int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction); @Override int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction); void setScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight); void setScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth); @Override void setBackground(Color bg); @Override void setBackgroundPainter(Painter p); @Override Painter getBackgroundPainter(); @Override boolean isPaintBorderInsets(); @Override void setPaintBorderInsets(boolean paintBorderInsets); @Override void paint(Graphics g);  }
@Test public void testPainterChangeListener() { JXPanel panel = new JXPanel(); final MattePainter painter = new MattePainter(Color.RED); int listenerCount = painter.getPropertyChangeListeners().length; panel.setBackgroundPainter(painter); assertEquals(listenerCount +1, painter.getPropertyChangeListeners().length); panel.setBackgroundPainter(null); assertEquals(listenerCount, painter.getPropertyChangeListeners().length); }