Link to home
Start Free TrialLog in
Avatar of csalem01
csalem01Flag for Afghanistan

asked on

java JFileChooser crashes firefox

I have an applet that crashes firefox (by crash I mean completely freezes up and I have to open the task manager and kill the process) most of the time when a dialog from JFileChooser is created.  the applet is signed and it works fine in IE.  Does anyone know of a workaround for this, or another class that I can use?  Here's my java code:

import java.security.AccessController;
import java.security.PrivilegedAction;

import javax.swing.JApplet;
import javax.swing.JFileChooser;


public class TestJFileChooser extends JApplet{

      public void init(){}
      
      public void selectLocalFiles(){
            AccessController.doPrivileged(new PrivilegedAction<Object>(){
                  public Object run() {
                        JFileChooser jfc = new JFileChooser();
                        jfc.setMultiSelectionEnabled(true);

                        int returnval = jfc.showOpenDialog(null);    //this is where it crashes
                        if(returnval == JFileChooser.APPROVE_OPTION){
                              
                        }
                        return null;
                  }                  
            });            
      }
}

and here's the html page:

<html>
<body>

<applet id='imagemgr' name='imagemgr' code='TestJFileChooser.class' archive="TestJFileChooser3.jar" mayscript='mayscript' width=0 height=0></applet>


<a href="javascript: addAttachment()">Test JFileChooser</a>

<script>
function addAttachment(){
      var selectedfile = new Array();
      var startpos = 0;
      document.getElementById("imagemgr").selectLocalFiles();
}
</script>
</body>
</html>
Avatar of sciuriware
sciuriware

May be that's the reason that FireFox 3.0.1 is released.

FireFox: Help-> check for updates ......

;JOOP!
Avatar of csalem01

ASKER

It actually crashes more often with the update.  Seems to crash everytime now.

It only appears to crash if I call the selectLocalFiles() function from javascript.  I added a button to the applet that calls that function and it works fine.
Let Mozilla know about this.

;JOOP!
I reported it to mozilla.  So they'll probably get to it 3 years from now, if ever :(

Can you think of any workaround, or anything besides the JFileChooser that I can use?

Do you think I should report this to Sun as well, I wasn't sure if this would be a bug in firefox or the java plug-in?

Some clients have been complaining about this, so any workaround you can think of would be helpfull
ASKER CERTIFIED SOLUTION
Avatar of sciuriware
sciuriware

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hopefully java 6u10 fixes the problem, since they're completely changing how applets work.