Table: fixed selection background of checkbox in table cell

This commit is contained in:
Karl Tauber
2019-11-14 12:33:04 +01:00
parent a907cd7f46
commit 3ba8133890
2 changed files with 18 additions and 0 deletions

View File

@@ -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

View File

@@ -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 );