All Swing/NetBeans-based Java GUI applications seem to have the same WM_CLASS
value:
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"
This parameter can be viewed by issuing xprop
command and pointing to the window. The practical purpose of customizing it is to let Mac-like docks (AWN, for example (and, perhaps, Ubuntu's Unity)) distinguish the application windows and group them under the application's pinned launcher icon. For this to work StartupWMClass
parameter is to be set accordingly in the .application
file in ~/.local/share/applications
or /usr/share/applications
. Needless to say, AWN (and analogues) get confused in case more than one application uses the same string for WM_CLASS
.
This blog post found the field in Toolkit
that controls it, named awtAppClassName
. It suggests using reflection to modify it:
Toolkit xToolkit = Toolkit.getDefaultToolkit();
java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(xToolkit, applicationName);
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