When running a Java Swing application in Opensuse, the name of the main class (com-simontuffs-onejar-Boot
) appears at the top of the screen. How do I set that to be the title I want?
Version info:
/etc/SUSE-release
openSUSE 12.1 (i586)
VERSION = 12.1
CODENAME = Asparagus
uname -a
Linux pax22 3.1.0-1.2-default #1 SMP Thu Nov 3 14:45:45 UTC 2011 (187dde0) i686 i686 i386 GNU/Linux
java -version
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)
Did you try JFrame.setTitle(String)
, e.g. yourJFrame.setTitle("Title to display")
? I don't have an openSUSE box available at the moment to try it out myself…
EDIT: As it turns out (see comments, repeated it here for the sake of readability), it's a Gnome specific issue. This should resolve the issue:
Toolkit xToolkit = Toolkit.getDefaultToolkit();
java.lang.reflect.Field awtAppClassNameField =
xToolkit.getClass().getDeclaredField("awtAppClassName");
awtAppClassNameField.setAccessible(true);
awtAppClassNameField.set(xToolkit, applicationName);
See this blog post for more information.
If the setTitle(String)
does not work for you, look to deploy using Java Web Start. It can set an app. title on most platforms, and do much more besides.
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