aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFileChooser: Exception while removing reference: java.lang.InterruptedException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser: Exception while removing reference: java.lang.InterruptedException" Watch "JFileChooser: Exception while removing reference: java.lang.InterruptedException" New topic
Author

JFileChooser: Exception while removing reference: java.lang.InterruptedException

Rafal Kawecki
Ranch Hand

Joined: Feb 08, 2011
Posts: 30

Hi all,

I've been working lately on a Swing application. I created a simple generic form-like JDialog (Label - Input Text; ...; Lable - Input Text; Submit).
I devolope mainly on Ubuntu with Sun JDK 1.6 u24.

No issues have been identified but few days ago I compiled and run this app on Windows 7, with exactly the same java version and a problem occured.
Additional functionality is that the form allows user to choose a file. User clicks a JButton and a JFileChooser shows up. When OK is chosen absolute file path is displayed in a JTextField. Everything takes place in Event Driven Thread.

I implemented a Window Closing listener to dispose a main JFrame (and the form-like JDialog) and call System.exit(0). When the app is closed occasionaly the following exception is thrown by Java 2D Disposer thread (which seems to be some intenral mechanism):
This happens only when using JFileChooser. If there are only JLables and JTextFieldeverything works fine.
As a temp solution I advise System to run the GC and it works as well.

I tried to run jvisualvm to idetify all threads and objects but everytime I create a dump the problem does not occur.

I created a simple app which generates the Exception with similar frequency as my main app:


I googled a little but this issue does not seem to be popular.
I had upgraded Java version to the latest release u26 but it didn't change anything.

Can any of you please try to run this code and check if it happens ?

Thanks in advance
Rafal
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

First of all, it's Event Dispatcher Thread, not Event Driver Thread.

It looks like there's some event still in the event queue. I'm not sure why; perhaps the setVisible(false) after the call to dispose(). It's unnecessary, as dispose() will already hide the dialog, so what happens if you remove this statement?

If that doesn't solve the problem, what steps do you need to take to reproduce it? Because I tried to get that error but no such luck. My steps:
- launch the application
- click the button
- select a file
- press OK in the JFileChooser
- either press OK in the main dialog or close it using the X


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rafal Kawecki
Ranch Hand

Joined: Feb 08, 2011
Posts: 30

Rob Spoor wrote:First of all, it's Event Dispatcher Thread, not Event Driver Thread.
Sorry, my mistake. I have no idea why I wrote Driver

Rob Spoor wrote:It looks like there's some event still in the event queue. I'm not sure why; perhaps the setVisible(false) after the call to dispose(). It's unnecessary, as dispose() will already hide the dialog, so what happens if you remove this statement?
The same Exception was thrown.

Rob Spoor wrote:If that doesn't solve the problem, what steps do you need to take to reproduce it? Because I tried to get that error but no such luck. My steps:
- launch the application
- click the button
- select a file
- press OK in the JFileChooser
- either press OK in the main dialog or close it using the X
That is exactly what you need to do. That does not matter if you use X or OK.

Which OS do you use ? How many times did you try to run the app ?

Thanks
Rafal
Rafal Kawecki
Ranch Hand

Joined: Feb 08, 2011
Posts: 30

Dispose desc in Java 6 API says:
public void dispose()
Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. ...

So i updated the code to:but still the same issue.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

I use Windows 7 Pro 64-bit with Java 1.6.0_26 32-bit, and I tried at least 10 times. No errors at all.
Rafal Kawecki
Ranch Hand

Joined: Feb 08, 2011
Posts: 30

The only difference is that I have the Windows Enterprise version.

I am not an advanced Swing GUI programmer but this code seems to be ok. Besides the error does not seem to be harmful, is it generated after all my operations are finished. Anyway, thanks for your help.
Rafal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFileChooser: Exception while removing reference: java.lang.InterruptedException