Skip to content

Commit

Permalink
Table: fixed selection background of checkbox in table cell
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCharly committed Nov 14, 2019
1 parent a907cd7 commit 3ba8133
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
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;

/**
Expand Down Expand Up @@ -90,6 +92,21 @@ protected void uninstallDefaults( AbstractButton b ) {
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 );
Expand Down

0 comments on commit 3ba8133

Please sign in to comment.