I'm going to make a wild guess here...
* PreInstantiate is in the same file as CustomFileFilter
* both are inner classes -- i.e. nested classes but not static classes
* main is not marked as static -- if it was the compiler would have caught the problem
The "NPE" is caused on the ctor to CustomerFileFilter which is actually:
new CustomerFileFilter([Outer Class], "csv", "csv files")
in the byte-code. Isn't "syntatic sugar" fun!
Make your main() a static method and see what the compiler says.
The lesson here is to always make nested classes static unless you really want them to be inner classes.
~rmp
-----Original Message-----
From: philp9 [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 26, 2003 8:32 AM
To: [EMAIL PROTECTED]
Subject: inner classes, threads, swing graphics in jar files
Hi,
I have a problem running the following code from a jar file. I am
pre-instantiating a JFileChooser in a thread. It works when I run the code
outside of a jar file, but generates
java.lang.NullPointerException
at WizardView$PreInstantiate.run(WizardView.java:357)
at java.lang.Thread.run(Thread.java:484)
58 // instantiate a JfileChooser straight away to make it quickly open
59
60 PreInstantiate pi = new PreInstantiate();
61 Thread tr = new Thread(pi);
62 tr.setPriority(tr.MAX_PRIORITY);
63 tr.start();
jfc, csvFilter, and txtFilter are private class variables
350 // Inner class for pre-instantiate JfileChooser
351 protected class PreInstantiate implements Runnable
352 {
353 public void run()
354 {
355 jfc = new JFileChooser("../");
356 jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
357 csvFilter = new CustomFileFilter("csv", "csv files");
358 txtFilter = new CustomFileFilter("txt", "text files");
359 jfc.addChoosableFileFilter(txtFilter);
360 jfc.addChoosableFileFilter(csvFilter);
361 bSelect.setActionCommand("selectButton");
362 bSelect.setEnabled(true);
363 }
364 }
Any help would be appreciated.
Also I have a problem with the graphics display running from a jar file.
When I open the main app the outer boarder of the window shows, but the
inside of the window is blank for sometime, before it appears, the internal
window backgrounds
are transparent through to the background of the window. It doesn't do this
outside a jar file. Any ideas?
Regards,
Phil
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing