Hi, We got a report [1] for a very simple fix so GTKLookAndFeel will return the right TextPane.background color.
Currently UIManager.getColor("TextPane.background") will ignore the theme color and always return a white color for GTKLookAndFeel due to inheritance from BasicLookAndFeel - that is incorrect and fails badly for dark themes. Seems to affect various OpenJDK versions - I can confirm it from 8 to 16 after looking at the source code, haven't checked on 7. Please note that the JTextPane opens using all the correct theme colors, it's the UIManager.getColor("TextPane.background") call that fails since GTKLookAndFeel does not currently set it. If the patch below fails to display correctly the original one can be fetched directly from the bug report [2]. --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java @@ -349,6 +349,7 @@ Double defaultCaretAspectRatio = Double.valueOf(0.025); Color caretColor = table.getColor("caretColor"); Color controlText = table.getColor("controlText"); + Color text = table.getColor("text"); Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { "ctrl C", DefaultEditorKit.copyAction, @@ -1150,6 +1151,7 @@ "TextField.font", new FontLazyValue(Region.TEXT_FIELD), + "TextPane.background", text, "TextPane.caretForeground", caretColor, "TextPane.caretAspectRatio", defaultCaretAspectRatio, "TextPane.caretBlinkRate", caretBlinkRate, References: [1] https://launchpad.net/bugs/1894419 [2] https://launchpadlibrarian.net/496501072/gtk-laf-textpane-respect-dark-mode.diff Cheers! -- Tiago Stürmer Daitx Software Engineer tiago.da...@canonical.com PGP Key: 4096R/F5B213BE (hkp://keyserver.ubuntu.com) Fingerprint = 45D0 FE5A 8109 1E91 866E 8CA4 1931 8D5E F5B2 13BE