ScrollPane: paint disabled border if view component (e.g. JTextPane) is disabled

This commit is contained in:
Karl Tauber
2019-12-01 18:23:30 +01:00
parent 404e80082c
commit 2cc8327a08
2 changed files with 15 additions and 2 deletions

View File

@@ -8,6 +8,8 @@ FlatLaf Change Log
for improved compatibility with IntelliJ platform themes (e.g. for Vuesion, for improved compatibility with IntelliJ platform themes (e.g. for Vuesion,
Spacegray and Material Design Dark themes). Spacegray and Material Design Dark themes).
- Button: Fixed help button styling in IntelliJ platform themes. - Button: Fixed help button styling in IntelliJ platform themes.
- ScrollPane: Paint disabled border if view component (e.g. JTextPane) is
disabled.
## 0.20 ## 0.20

View File

@@ -95,12 +95,23 @@ public class FlatBorder
} }
protected Paint getBorderColor( Component c ) { protected Paint getBorderColor( Component c ) {
boolean enabled = c.isEnabled() && (!(c instanceof JTextComponent) || ((JTextComponent)c).isEditable()); return isEnabled( c )
return enabled
? (isFocused( c ) ? focusedBorderColor : borderColor) ? (isFocused( c ) ? focusedBorderColor : borderColor)
: disabledBorderColor; : disabledBorderColor;
} }
protected boolean isEnabled( Component c ) {
if( c instanceof JScrollPane ) {
// check whether view component is disabled
JViewport viewport = ((JScrollPane)c).getViewport();
Component view = (viewport != null) ? viewport.getView() : null;
if( view != null && !isEnabled( view ) )
return false;
}
return c.isEnabled() && (!(c instanceof JTextComponent) || ((JTextComponent)c).isEditable());
}
protected boolean isFocused( Component c ) { protected boolean isFocused( Component c ) {
if( c instanceof JScrollPane ) { if( c instanceof JScrollPane ) {
JViewport viewport = ((JScrollPane)c).getViewport(); JViewport viewport = ((JScrollPane)c).getViewport();