From 3ba8133890d0f68b7746dc21722ac13ad8560605 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 14 Nov 2019 12:33:04 +0100 Subject: [PATCH] Table: fixed selection background of checkbox in table cell --- CHANGELOG.md | 1 + .../formdev/flatlaf/ui/FlatRadioButtonUI.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f284b72e..8e46fcc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ FlatLaf Change Log ## Unreleased - Support using IntelliJ platform themes (.theme.json files). +- Fixed selection background of checkbox in table cell. ## 0.18 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java index de5f7f7a..210de4f7 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java @@ -21,10 +21,12 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.AbstractButton; +import javax.swing.CellRendererPane; import javax.swing.JComponent; import javax.swing.LookAndFeel; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicRadioButtonUI; /** @@ -90,6 +92,21 @@ public class FlatRadioButtonUI defaults_initialized = false; } + @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() ); + } + + super.paint( g, c ); + } + @Override protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) { FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText );