Button: do not paint border and background if contentAreaFilled == false

This commit is contained in:
Karl Tauber
2019-08-20 18:35:56 +02:00
parent aa32e50a51
commit d84ecd3bea
2 changed files with 8 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ public class FlatButtonBorder
{
@Override
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
if( !FlatButtonUI.isContentAreaFilled( c ) )
return;
Graphics2D g2 = (Graphics2D) g.create();
try {
FlatUIUtils.setRenderingHints( g2 );

View File

@@ -47,13 +47,17 @@ public class FlatButtonUI
return instance;
}
static boolean isContentAreaFilled( Component c ) {
return c instanceof AbstractButton && ((AbstractButton)c).isContentAreaFilled();
}
static boolean isDefaultButton( Component c ) {
return c instanceof JButton && ((JButton)c).isDefaultButton();
}
@Override
public void update( Graphics g, JComponent c ) {
if( c.isOpaque() ) {
if( c.isOpaque() && FlatButtonUI.isContentAreaFilled( c ) ) {
FlatUIUtils.paintParentBackground( g, c );
if( c.isEnabled() ) {