Anyone know where the synth XML file is supposed to be located. My app
never seems to pick it up no matter where I put it. I run a *.bat file
to execute my app and the main file is in a jar in the bin dir and my
xml file is not in the jar, but also in the bin dir. I put the xml file
in the String path below.
Here is what I have ...
---
SynthLookAndFeel synth = new SynthLookAndFeel();
String synthXML = new String("bin"
+ System.getProperty("file.separator")
+ "mylaf.xml");
Class aClass = Eiger.class;
InputStream is = aClass.getResourceAsStream(synthXML);
if (is == null) {
// Always falls here ...
System.err.println("Unable to find theme configuration");
}
synth.load(is, aClass);
UIManager.setLookAndFeel(synth);
---
Any help much appreciated.
> Anyone know where the synth XML file is supposed to be located.
What's a 'synth'?
>.. My app
> never seems to pick it up no matter where I put it. I run a *.bat file
> to execute my app and the main file is in a jar in the bin dir
Where is the bat file?
>..and my xml file is not in the jar, but also in the bin dir.
Is it in the jar or not? 'not' implies no, but 'also' implies yes.
>..I put the xml file in the String path below.
Arg!! Strings for specifying paths (shudder).
> Here is what I have ...
>
[quoted text clipped - 3 lines]
> + System.getProperty("file.separator")
> + "mylaf.xml");
You need to find out more, right this.
<sscce>
import java.io.*;
import java.net.*;
public class IO {
public static void main(String[] args) {
try {
File currentDir = new File(".");
System.out.println( "Current Directory: " +
currentDir.getCanonicalPath() );
URL thisClass = currentDir.
getClass().getResource(
"IO.class");
System.out.println( "URL this class (no prefix): " +
thisClass );
thisClass = currentDir.
getClass().getResource(
System.getProperty("file.separator")
+ "IO.class");
System.out.println( "URL this class 'file.separator': " +
thisClass );
thisClass = currentDir.
getClass().getResource(
"/"
+ "IO.class");
System.out.println( "URL this class (leading '/'): " +
thisClass );
System.out.println("System.getProperty('file.separator') " +
System.getProperty("file.separator"));
} catch(Exception e) {
e.printStackTrace();
}
}
}
</sscce>
> if (is == null) {
> // Always falls here ...
> System.err.println("Unable to find theme configuration");
> }
If that fails, it seems little point to continue to..
> synth.load(is, aClass);
// is is null!
> UIManager.setLookAndFeel(synth);
// setLookAndFeel(null) ..assuming it got this far.
> Any help much appreciated.
Compile and run the source and see if that clarifies it for you.
HTH

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Wizumwalt@gmail.com - 27 Jun 2005 20:36 GMT
I added that code to the section of my app where I do all this and w/
the exception of the currentDir working, all the other lines printed
'null' I *think* because IO.class (which I substitued w/ the class name
I wrote this code in) is in a jar file and I'm not sure how to get this
class out of a jar file.
Synth can be found in the J2SE in this package ...
javax.swing.plaf.synth
The following code throws an IOException when executing the
'InputStream is = ...' line and I can't quite figure out why.
---
...
// I'm not sure if this line is executing correctly because
// MyClass.class is in a jar file. But aClass.toString()
// prints the correct class name (though I don't understand how).
Class aClass = MyClass.class;
// IOException thrown here, probably because I don't see how
// the previous line can get 'MyClass'
InputStream is = aClass.getResourceAsStream("myTheme.xml");
if (is == null) {
System.err.println("Unable to find theme configuration");
}
synth.load(is, aClass);
---
Does that sound right? I'm thinking I'm not getting 'MyClass.class' out
of the jar correctly, nor do I know how.
Any help much appreciated.
Wizumwalt@gmail.com - 27 Jun 2005 20:48 GMT
Ok, I don't beleive it's an IOException being thrown, but an Exception
certainly is that says ...
[code]
Exception: You must supply an InputStream;, Class and StyleFactory
java.lang.IllegalArgumentException: You must supply an InputStream;,
Class and StyleFactory
[/code]
I just don't understand this error as I am supplying a Class and
StyleFactory for Synth.
Andrew Thompson - 27 Jun 2005 22:19 GMT
> Ok, I don't beleive it's an IOException being thrown, but an Exception
> certainly is that says ...
[quoted text clipped - 7 lines]
> I just don't understand this error as I am supplying a Class and
> StyleFactory for Synth.
Are you supplying an input stream?
(An InputStream that is not _null_?)
That first example should provide you with enough tips to
investigate this problem in more detail.
When in doubt, print out!
Another tip is, look at every parameter just before you hand
it to a method. You are making far too many assumptions on
this one.

Signature
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane