TextArea: fixed inactive and disabled background

This commit is contained in:
Karl Tauber
2019-08-21 20:18:08 +02:00
parent a691260e34
commit 0b02236c6b

View File

@@ -16,9 +16,12 @@
package com.formdev.flatlaf.ui;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTextAreaUI;
import javax.swing.text.JTextComponent;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JTextArea}.
@@ -31,4 +34,16 @@ public class FlatTextAreaUI
public static ComponentUI createUI( JComponent c ) {
return new FlatTextAreaUI();
}
@Override
protected void paintBackground( Graphics g ) {
JTextComponent c = getComponent();
g.setColor( !c.isEnabled()
? UIManager.getColor( "TextArea.disabledBackground" )
: (!c.isEditable()
? UIManager.getColor( "TextArea.inactiveBackground" )
: c.getBackground() ) );
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
}
}