bug: AbstractButton's ContentAreaFilled=false not honored when parent is a CellRendererPane

docs: AbstractButton:setContentAreaFilled

Sets the contentAreaFilled property. If true the button will paint the content area. If you wish to have a transparent button, such as an icon only button, for example, then you should set this to false. Do not call setOpaque(false). The default value for the the contentAreaFilled property is true.
This function may cause the component's opaque property to change.

The exact behavior of calling this function varies on a component-by-component and L&F-by-L&F basis.

Parameters:
b - if true, the content should be filled; if false the content area is not filled
This commit is contained in:
Bill Culp
2020-02-10 23:37:27 -08:00
parent 5796057a75
commit a1d5f65588

View File

@@ -121,8 +121,9 @@ public class FlatRadioButtonUI
// fill background even if opaque if
// - used as cell renderer (because of selection background)
// - if background was explicitly set to a non-UIResource color
if( !c.isOpaque() &&
(c.getParent() instanceof CellRendererPane || !(c.getBackground() instanceof UIResource)) )
if( ( !c.isOpaque() &&
(c.getParent() instanceof CellRendererPane || !(c.getBackground() instanceof UIResource)))
|| c instanceof AbstractButton && ((AbstractButton) c).isContentAreaFilled() )
{
g.setColor( c.getBackground() );
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );