Is there a way for a Java Swing desktop application that runs in Gnome (3.14) on Linux (Debian) to make Gnome use the dark-themed (Adwaita) version of the window decoration?
I am using a custom dark Swing look-and-feel, and the only thing that is really annoying is that the title bar (native Gnome) is very bright. I already have used the Tweak tool to use Adwaita system-wide, but this doesn't kick in for applications that do not explicitly support dark-theme (e.g. Iceweasel, Icedove, Gimp, Libre Office, ...)
Here's a screenshot that illustrates the problem:
Simply replace the main theme with the dark one (in a special copy of Adwaita in your home dir): Then use a tool like gnome-tweak-tool to set Darkwaita as your gtk theme, and the changes should take effect immediately.
GitHub - k33ptoo/Java-Swing-Custom-Titlebar: A project to showcase an OS aware Title bar to replace the default swing title bar which you may be able to customize and add more components. … Failed to load latest commit information.
If you want only to use the Adwaita Dark theme at night time, you can install the Dark Mode Toggle extension. It’s a neat little tool that, once installed correctly, provides a quick switch on the panel that can swap you from light and dark Gnome Shell themes.
JWindow is a part of Java Swing and it can appear on any part of the users desktop. It is different from JFrame in the respect that JWindow does not have a title bar or window management buttons like minimize, maximize, and close, which JFrame has. JWindow can contain several components such as buttons and labels. Constructor of the class are:
Ok, I found a viable solution for my specific system, so I will show what I did here. It is related to this question. In the accepted answer you can see that the issue is with legacy Gtk-2 applications, and that includes Java apparently. In the comments section there is a link to a Adwaita-Dark clone that applies the dark theme also to Gtk-2.
Unfortunately that theme is out-of-sync with Debian Jessie / Gnome 3.14 somehow, and if one installs that theme most widgets are broken in Iceweasel, Icedove etc. However. Since I don't care about the widgets but only the window title bar here, you can selectively use that clone only for the window decoraction.
So I downloaded that clone, and placed a symlink in ~/.local/share/themes/adwaita-again
(you can use any name here it seems). Then in the Tweak tool, just flip the window style, like so:
And voilà, window title bars are dark for all applications:
This is also great when working with IntelliJ IDEA and "Darcula" theme. Linux FTW.
Edit: It seems the above approach does not fully work, at least after rebooting I am seeing the bright colours again. I found a more simple variant now: Copy the original Adwaita theme and patch the Metacity file. I have created a repository with my patched version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With