mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
CheckBox and RadioButton: fill component background as soon as background color is different to default background color, even if component is not opaque (which is the default). This paints selection if using the component as cell renderer a Table, Tree or List (better fix for #77)
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,6 +1,16 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## 1.0-rc2-SNAPSHOT
|
||||
|
||||
#### Fixed bugs
|
||||
|
||||
- CheckBox and RadioButton: Fill component background as soon as background
|
||||
color is different to default background color, even if component is not
|
||||
opaque (which is the default). This paints selection if using the component as
|
||||
cell renderer a Table, Tree or List.
|
||||
|
||||
|
||||
## 1.0-rc1
|
||||
|
||||
#### New features and improvements
|
||||
|
||||
@@ -27,7 +27,6 @@ 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;
|
||||
import com.formdev.flatlaf.icons.FlatCheckBoxIcon;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
@@ -58,6 +57,8 @@ public class FlatRadioButtonUI
|
||||
protected int iconTextGap;
|
||||
protected Color disabledText;
|
||||
|
||||
private Color defaultBackground;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
@@ -74,6 +75,8 @@ public class FlatRadioButtonUI
|
||||
iconTextGap = FlatUIUtils.getUIInt( prefix + "iconTextGap", 4 );
|
||||
disabledText = UIManager.getColor( prefix + "disabledText" );
|
||||
|
||||
defaultBackground = UIManager.getColor( prefix + "background" );
|
||||
|
||||
defaults_initialized = true;
|
||||
}
|
||||
|
||||
@@ -120,7 +123,7 @@ public class FlatRadioButtonUI
|
||||
// - if background was explicitly set to a non-UIResource color
|
||||
if( !c.isOpaque() &&
|
||||
((AbstractButton)c).isContentAreaFilled() &&
|
||||
!(c.getBackground() instanceof UIResource) )
|
||||
(c.getBackground() != defaultBackground) )
|
||||
{
|
||||
g.setColor( c.getBackground() );
|
||||
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.awt.Graphics2D;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JViewport;
|
||||
@@ -34,7 +33,6 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicTableUI;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import com.formdev.flatlaf.util.Graphics2DProxy;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
@@ -137,12 +135,6 @@ public class FlatTableUI
|
||||
oldIntercellSpacing = table.getIntercellSpacing();
|
||||
table.setIntercellSpacing( intercellSpacing );
|
||||
}
|
||||
|
||||
// checkbox is non-opaque in FlatLaf and therefore would not paint selection
|
||||
// --> make checkbox renderer opaque (but opaque in Metal or Windows LaF)
|
||||
TableCellRenderer booleanRenderer = table.getDefaultRenderer( Boolean.class );
|
||||
if( booleanRenderer instanceof JCheckBox )
|
||||
((JCheckBox)booleanRenderer).setOpaque( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user