<Swing Dev> RFR: 8058704: Nimbus does not honor JTextPane background color [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.java.net
Thu Aug 5 08:46:30 UTC 2021
On Thu, 5 Aug 2021 08:37:07 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> The Nimbus look and feel ignores the configured background color of a JTextPane and always uses white.
>> Every other look and feel tested (Metal, Motif, and Windows) correctly honors the configured background color of a JTextPane.
>> Issue seems to be in the hardcoded background color in nimbus skin which is rectified via the fix.
>> After this fix, the background color is correctly updated to whatever is being set via JTextPane.setBackground().
>>
>> CI all test run is green.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Use background componentPropertyName
Restored "shape" tag and now tackling the bug from the fact that JTextField/JTextARea setbackground works unlike JTextPane/EditorPane.
It seems TextPanePainter class is generated from skin template where for JTextField/Area we have
private void paintBackgroundEnabled(Graphics2D g) {
this.rect = this.decodeRect1();
g.setPaint((Color)this.componentColors[0]);
g.fill(this.rect);
}
but for JTextPane/EditorPane, we have
private void paintBackgroundEnabled(Graphics2D g) {
this.rect = this.decodeRect1();
g.setPaint((Color)this.color2);
g.fill(this.rect);
}
where color2 is NimubsLightBackground so it seems to always paint white.
Proposed fix is to add background componentPropertyName for ENABLED state (for the fact
getContext is always called with SynthContext context = getContext(comp, ENABLED);
so that correct background component color is painted.`
-------------
PR: https://git.openjdk.java.net/jdk/pull/4930
More information about the swing-dev
mailing list