When embedding the EditLive! Swing SDK in to a Java application, developers may want to use static resources from within the application JAR file. These resources might be the EditLive! configuration file, stylesheets or even images within the content. Since Java can provide a URL to resources within a jar (or accessible by any form of class loader), you can use that URL with EditLive! to access the resources. The Class.getResource(String) method is used to retrieve a URL to your resources.
As an example, to set the configuration file to a resource called “eljconfig.xml” in the same package as the current class, use:
You can also use this URLs within the HTML you pass to EditLive! So to insert an image called “myimage.png” from the same package as the current class, you can use:
editlive.insertHTMLAtCursor("<img src='" + getClass().getResource("myimage.png") + "' />");
If you have a number of resources you want to reference from within the HTML, you can set the base URL of EditLive! to a resource within your jar file. For example:
The resource “myimage.png” must exist. You can then reference any resource in the same package in the HTML by using just the file name. For example:
<img src="otherImage.png" />
See the JavaDoc for getResource for details on exactly how the URLs to resources are generated and how to reference resources in other packages.