JDK-5056424 : Loading a SynthStyle and its resources from any URL
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-06-02
  • Updated: 2017-05-16
  • Resolved: 2005-09-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b53Fixed
Name: gm110360			Date: 06/02/2004

The current "load" method of SynthLookAndFeel requires to pass a "Class" object to resolve the resources inside the style: "load(InputStream input, Class<?> resourceBase)".

Now let's suppose I have written a style made of several images (I'm using the SynthLookAndFeel and no custom painters). In the style file, I reference the images relatively to the style file.

I have the following files in the "mystyle" folder:

Case 1: I have my style and icons in the jar of my application.
Solution 1:
I need to have a "Class" in the same package of "style.xml". This class will serve as a hook to get the resources. I'm ok with that.

Case 2: I have several styles packaged, each packaged in zip files, those zip files are not in the classpath. How can I load my styles?
Solution 2.1:
I do not see any way to do it with the current implementation. If I had a method like "load(URL styleXml)" where the styleXML url context would be used to load the resources, it would be enough. Better would be to support this concept of "self-contained themes" (aka themepacks in SkinLF) and to be able to load the style with "loadStyle(URL styleZIP)".
Solution 2.2:
Write my own custom "SynthParser" and fill the SynthStyleFactory from this new "SynthParser". Should not this be built in Swing instead?

Having an easier way to load the style from any location would make it possible to bundle styles in one zip/jar theme. This will ease the job of graphics designer and could help to spread the concept of SynthLookAndFeel and style files (having the equivalent of www.themexp.org but with Java themes).

New methods to be added to SynthLookAndFeel to load a theme from a "zip file" or to provide an URL as the resourceBase instead of a class.
(Incident Review ID: 275571) 

EVALUATION Name: sh120115 Date: 06/02/2004 ###@###.###, thought you might want to own this one for a bit. ###@###.### 2004-06-02 The class is used as the base, we could certainly ues a URL as the base too. This is a good idea and should be added. ###@###.### 2004-06-04