ScrollPane: paint background so that corners have same color as scroll bars

This commit is contained in:
Karl Tauber
2019-08-22 13:20:48 +02:00
parent c706b0d67b
commit 436fdf0bd5
3 changed files with 27 additions and 4 deletions

View File

@@ -45,6 +45,7 @@ public abstract class FlatLaf
extends BasicLookAndFeel
{
private static final String VARIABLE_PREFIX = "@";
private static final String REF_PREFIX = VARIABLE_PREFIX + "@";
private static final String GLOBAL_PREFIX = "*.";
private BasicLookAndFeel base;
@@ -169,7 +170,7 @@ public abstract class FlatLaf
if( !key.startsWith( GLOBAL_PREFIX ) )
continue;
String value = resolveVariable( properties, (String) e.getValue() );
String value = resolveValue( properties, (String) e.getValue() );
globals.put( key.substring( GLOBAL_PREFIX.length() ), parseValue( key, value ) );
}
@@ -190,7 +191,7 @@ public abstract class FlatLaf
if( key.startsWith( VARIABLE_PREFIX ) || key.startsWith( GLOBAL_PREFIX ) )
continue;
String value = resolveVariable( properties, (String) e.getValue() );
String value = resolveValue( properties, (String) e.getValue() );
defaults.put( key, parseValue( key, value ) );
}
} catch( IOException ex ) {
@@ -198,13 +199,16 @@ public abstract class FlatLaf
}
}
private String resolveVariable( Properties properties, String value ) {
private String resolveValue( Properties properties, String value ) {
if( !value.startsWith( VARIABLE_PREFIX ) )
return value;
if( value.startsWith( REF_PREFIX ) )
value = value.substring( REF_PREFIX.length() );
String newValue = properties.getProperty( value );
if( newValue == null )
System.err.println( "variable '" + value + "' not found" );
System.err.println( "variable or reference '" + value + "' not found" );
return newValue;
}

View File

@@ -17,6 +17,8 @@
package com.formdev.flatlaf.ui;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.FocusEvent;
@@ -83,6 +85,22 @@ public class FlatScrollPaneUI
}
}
@Override
public void update( Graphics g, JComponent c ) {
if( c.isOpaque() ) {
FlatUIUtils.paintParentBackground( g, c );
// paint background so that corners have same color as scroll bars
Insets insets = c.getInsets();
g.setColor( c.getBackground() );
g.fillRect( insets.left, insets.top,
c.getWidth() - insets.left - insets.right,
c.getHeight() - insets.top - insets.bottom );
}
paint( g, c );
}
//---- class Handler ------------------------------------------------------
/**

View File

@@ -88,6 +88,7 @@ ScrollBar.width=10
#---- ScrollPane ----
ScrollPane.border=com.formdev.flatlaf.ui.FlatBorder
ScrollPane.background=@@ScrollBar.track
#---- TextArea ----