InterruptedException after cancel file open dialog - 1.6.0_26

后端 未结 5 593
抹茶落季
抹茶落季 2020-12-31 13:06

The output from the code that follows is:

java.vendor     Sun Microsystems Inc.
java.version    1.6.0_26
java.runtime.version    1.6.0_26-b03
sun.arch.data.m         


        
5条回答
  •  自闭症患者
    2020-12-31 13:28

    The difference I saw between the code in the blog post is the scope of the JFileChooser. In the blog post the object is a local variable within the onClickedButton function. In your example the object is defined at the class level. I assume being a local variable gives the Disposer thread more time to clear the JFileChooser object.

    When I made the the file chooser object a local variable in the actionPerformed method block in your example, the exception did not occur. I did test it around ten times, Both running the application through eclipse and through the command line. The exception did not occur.

    If the exception still occurs, you can initializing a file chooser object in the constructor of GUI but not assigning it to anything. I assume here it acts as an early initialization and disposal of a heavy weight swing object.

    Hope this helps.

提交回复
热议问题