mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-14 07:47:12 -06:00
CheckBox and RadioButton: Opaque flag is no longer ignored when checkbox is used as table cell renderer (issue #77)
this fix replaces/improves fix made in commit 3ba8133890
This commit is contained in:
@@ -10,6 +10,8 @@ FlatLaf Change Log
|
|||||||
(e.g. 1000).
|
(e.g. 1000).
|
||||||
- Added Java 9 module descriptor to `flatlaf-extras-<version>.jar` and
|
- Added Java 9 module descriptor to `flatlaf-extras-<version>.jar` and
|
||||||
`flatlaf-swingx-<version>.jar`.
|
`flatlaf-swingx-<version>.jar`.
|
||||||
|
- CheckBox and RadioButton: Flag `opaque` is no longer ignored when checkbox or
|
||||||
|
radio button is used as table cell renderer. (issue #77)
|
||||||
|
|
||||||
|
|
||||||
## 0.34
|
## 0.34
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.awt.Graphics;
|
|||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.CellRendererPane;
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -122,11 +121,10 @@ public class FlatRadioButtonUI
|
|||||||
public void paint( Graphics g, JComponent c ) {
|
public void paint( Graphics g, JComponent c ) {
|
||||||
// fill background even if not opaque if
|
// fill background even if not opaque if
|
||||||
// - contentAreaFilled is true and
|
// - contentAreaFilled is true and
|
||||||
// - used as cell renderer (because of selection background)
|
// - if background was explicitly set to a non-UIResource color
|
||||||
// - or if background was explicitly set to a non-UIResource color
|
|
||||||
if( !c.isOpaque() &&
|
if( !c.isOpaque() &&
|
||||||
((AbstractButton)c).isContentAreaFilled() &&
|
((AbstractButton)c).isContentAreaFilled() &&
|
||||||
(c.getParent() instanceof CellRendererPane || !(c.getBackground() instanceof UIResource)))
|
!(c.getBackground() instanceof UIResource) )
|
||||||
{
|
{
|
||||||
g.setColor( c.getBackground() );
|
g.setColor( c.getBackground() );
|
||||||
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicTableUI;
|
import javax.swing.plaf.basic.BasicTableUI;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,6 +134,12 @@ public class FlatTableUI
|
|||||||
oldIntercellSpacing = table.getIntercellSpacing();
|
oldIntercellSpacing = table.getIntercellSpacing();
|
||||||
table.setIntercellSpacing( intercellSpacing );
|
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
|
@Override
|
||||||
|
|||||||
@@ -304,6 +304,8 @@ public class FlatInspector
|
|||||||
text += "Enabled: " + c.isEnabled() + '\n';
|
text += "Enabled: " + c.isEnabled() + '\n';
|
||||||
text += "Opaque: " + c.isOpaque() + (c instanceof JComponent &&
|
text += "Opaque: " + c.isOpaque() + (c instanceof JComponent &&
|
||||||
FlatUIUtils.hasOpaqueBeenExplicitlySet( (JComponent) c ) ? " EXPLICIT" : "") + '\n';
|
FlatUIUtils.hasOpaqueBeenExplicitlySet( (JComponent) c ) ? " EXPLICIT" : "") + '\n';
|
||||||
|
if( c instanceof AbstractButton )
|
||||||
|
text += "ContentAreaFilled: " + ((AbstractButton)c).isContentAreaFilled() + '\n';
|
||||||
text += "Focusable: " + c.isFocusable() + '\n';
|
text += "Focusable: " + c.isFocusable() + '\n';
|
||||||
text += "Left-to-right: " + c.getComponentOrientation().isLeftToRight() + '\n';
|
text += "Left-to-right: " + c.getComponentOrientation().isLeftToRight() + '\n';
|
||||||
text += "Parent: " + c.getParent().getClass().getName();
|
text += "Parent: " + c.getParent().getClass().getName();
|
||||||
|
|||||||
Reference in New Issue
Block a user