mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 23:08:42 +03:00
ScrollPane: paint background so that corners have same color as scroll bars
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 ------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -88,6 +88,7 @@ ScrollBar.width=10
|
||||
#---- ScrollPane ----
|
||||
|
||||
ScrollPane.border=com.formdev.flatlaf.ui.FlatBorder
|
||||
ScrollPane.background=@@ScrollBar.track
|
||||
|
||||
|
||||
#---- TextArea ----
|
||||
|
||||
Reference in New Issue
Block a user