Create a java.net.URL to refer to a CSS in a .jar file

Article ID: 2336
Last updated: 29 May, 2018
Article ID: 2336
Last updated: 29 May, 2018
Revision: 3
Views: 772
Posted: 28 Mar, 2007
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How do I create a java.net.URL to refer to a CSS in a .jar file?

Answer

Many setStyleSheet methods for many JViews objects expect a String in the form of a proper java.net.URL. If you wish to refer to a CSS style sheet in a .jar file, you can build an appropriate java.net.URL of the form:

jar:<jar url>!/<path to style sheet in JAR file>

For example:

jar:file:/home/files/app.jar!/myStyleFile.css

For more information, please refer to the documentation of java.net.URL and java.net.JarURLConnection.

For an application using IlvDiagrammer, please note that the IlvSDMEngine.setStyleSheets method will also set and use the specified URL as the base location to find the application resources. If you provide a URL to a CSS in a .jar file, the .jar file will become the base URL. Consequently, your graphical resources, such as images, symbols, and so on, need to be findable. You can make them findable either by placing them within the same .jar file, or by invoking a separate call to IlvSDMEngine.setBaseURL after setting the style sheets.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2336
Last updated: 29 May, 2018
Revision: 3
Views: 772
Posted: 28 Mar, 2007 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category