How can I set my Java system look and feel for JNLP apps?

为君一笑 提交于 2019-12-14 03:48:45

问题


I am running Gnome on OpenSuse. As a result, my system look and feel is GTK+, which has numerous ugly problems (see some of them here).

During development of my swing app, I can run the client from command line or IDE and specify VM parameter

-Dswing.systemlaf=com.sun.javax.swing.plaf.metal.CrossPlatformLookAndFeel

to make it look good.

But I don't know how to force Java Webstart to use this VM parameter when I start the application through JNLP.

edit: This has nothing to do with the programmatic ability to set the look & feel. The application does this properly.

My question is how to tell Java Webstart to use a VM parameter "swing.systemlaf" when it runs the myapp.jnlp file.


回答1:


Java Web Start allows certain JVM flags to be set with the java-vm-args attribute of the j2se element but you may use

<property name="key" value="overwritten"/>  

and set properties. it will be available through the System.getProperty and System.setProperties methods

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources




回答2:


You can always use UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());




回答3:


I know this subject is quite old now but it may be useful.

You can force the look and feel with the following environment variable:

export _JAVA_OPTIONS="-Dswing.systemlaf=com.sun.javax.swing.plaf.metal.CrossPlatformLookAndFeel"



回答4:


I believe you can configure properties in WebStart using the -userConfig command line option. The WebStart dialgos are part of the JRE installation, and not part of the application.



来源:https://stackoverflow.com/questions/2252420/how-can-i-set-my-java-system-look-and-feel-for-jnlp-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!