Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set title of java application opensuse

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)
like image 908
gerardw Avatar asked Dec 09 '22 23:12

gerardw


2 Answers

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.

like image 127
siegi Avatar answered Dec 11 '22 12:12

siegi


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.

like image 22
Andrew Thompson Avatar answered Dec 11 '22 12:12

Andrew Thompson