Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractButton's ContentAreaFilled=false not honored when parent is a CellRendererPane #58

Closed
hshafie opened this issue Feb 9, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@hshafie
Copy link

hshafie commented Feb 9, 2020

When the ContentAreaFilled property of an RadioButton or CheckBox is set to false and this kind of AbstractButton is painted by a CellRendererPane, its background color is still rendered. This behavior differs from what do the Windows, Metal, GTK+, Nimbus, etc, LAFs.

This behavior is implemented here in FlatLaf 0.26, com/formdev/flatlaf/ui/FlatRadioButtonUI.java:

@Override
public void paint( Graphics g, JComponent c ) {
	// 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)) )
	{
		g.setColor( c.getBackground() );
		g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
	}


PS: This is a very minor bug. Other than this, FlatLaf is fast, works great and looks gorgeous in my large, complex, Swing application. Thank you very much for your work!

@smileatom
Copy link

PR submitted #63

DevCharly added a commit that referenced this issue Feb 11, 2020
bug: AbstractButton's ContentAreaFilled=false not honored when parent is a CellRendererPane
DevCharly added a commit that referenced this issue Feb 11, 2020
@DevCharly
Copy link
Collaborator

@hshafie thanks for reporting.

This is now fixed in master branch.
To try it out you can use the latest snapshot (https://github.com/JFormDesigner/FlatLaf#snapshots).
A new release will be available in a few days.

@DevCharly DevCharly added the bug Something isn't working label Feb 11, 2020
@hshafie
Copy link
Author

hshafie commented Feb 12, 2020

To try it out you can use the latest snapshot (https://github.com/JFormDesigner/FlatLaf#snapshots).

No need to try the snapshot. I read your code and found that I made exactly the same modification

if( !c.isOpaque() && ((AbstractButton)c).isContentAreaFilled() &&... 

in my copy of FlatLaf 0.26 and I confirm that this change fixes the problem.

I will download and use FlatLaf 0.27 as soon as it will be available.

Many thanks!

@DevCharly
Copy link
Collaborator

released in 0.27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants