Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

JFileChooser is throwing NullPointerException  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a swing application that is using JFileChooser. When I click the Open menu item from File menu it should show the File dialog box where user can select the file.
This application is running in my machine but encounters problem in another machine. File dialog box is not showing and stack trace shows that NullPointerException is thrown by JFileChooser
My machine is a 64 bit Windows 7 while the other machine is Windows 7 32 bit. Both machine are using java 1.6
To verify if its because of the 32-bit, I tried in another Windows 7 32-bit and the same application is working.

I came across this article which identified it as bug but already fix in 1.4.2_04. Though I am using 1.6, just to make sure I also tried the suggested work around
I put System.setProperty("swing.disableFileChooserSpeedFix", "true"); in my code but still not working
I also tried to add java -Dswing.disableFileChooserSpeedFix=true to the batch file that is launching the application and still not working

Any other suggestions or idea on this? Thanks

Code Sample

Below is the stack trace

ERROR - Error occured while opening an existing timetable. null
caused by null java.lang.NullPointerException
at javax.swing.ImageIcon.<init><>
at javax.swing.ImageIcon.<init><>
at sun.swing.WindowPlaceBar.<init><>
at java.swing.plaf.basic.basicFileChooserUI.installUI<>
at javax.swing.JComponent.setUI<>
at javax.swing.JFileChooser.updateUI<>
at javax.swing.JFileChooser.setup<>
at javax.swing.JFileChooser.<init><>
at javax.swing.JFileChooser.<init><>

Posts: 3742
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that is the code you are running ?
The stack trace shows you calling the loadMDBFile method in the File_Open class, but your code is showing a class called FileChooserTester
Posts: 62180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing return null; is asking for trouble.
You have a method with a boolean return (why are you writing Boolean?) so users will expect it to tell them whether it opened the file or not. Users will expect to get true or false and to be able to use that value straight off without having to check for nulls.

Of course, as Joanne says, the method you are actually using may be different.

And welcome to the Ranch
Not so fast naughty spawn! I want you to know about
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!