Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:29:55+00:00 2026-05-31T01:29:55+00:00

I need to pop-up a file open dialog in a web page, and have

  • 0

I need to pop-up a file open dialog in a web page, and have the user select a file (not for upload!). Because I need access to the full file path, I cannot use a form/input. Thus, I use a signed Java applet.

In my test case a Java applet method is called from a javascript function. The applet method opens a file open dialog (JFileChooser). If left idle for approx. 30″, the applet gets killed by Safari(*). In my testing Chrome is nicer, it pops-up the “unresponsive” alert, whereas Firefox apparently doesn’t care.

IIUC, this is a Safari-specific behavior, but it is very inconvenient. I need that dialog to stay up until the user makes a choice. I looked at threading the JFileChooser but that path seems to be way more complicated, and doing all the work in Javascript alone is not possible, for known security reasons. Do you have a clean solution to this?

(*) JVM ends in an InterruptedException

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:29:57+00:00Added an answer on May 31, 2026 at 1:29 am

    Your problem stems from the fact that dialogs in Java behave as blocking method calls (its actually an amazing engineering trick how they do it that I wish other toolkits would adopt). So when your javascript invokes the method onto the Java code it’s waiting for that dialog to be dismissed. The browser detects that the javascript thread hasn’t returned in a while and simply decides it’s dead locked and kills it. Hence the Java applet goes down with the page.

    You’ll need to transition that into an asynchronous style interaction. The call Javascript makes should return immediately. You can use SwingUtilities.invokeLater() in Java to push that call off the Javascript calling thread. The trick then is once the dialog is dismissed you need Java to call Javascript. So you’ll have javascript register some sort of callback mechanism. Something like the following. I can’t remember how external javascript -> java works exactly so this is just pseudo code to illustrate the idea:

    function showFileDialog() {
        applet.showFileDialog( function( filepath ) {
           if( filepath ) {
              alert( "Hey they picked " + filepath );
           } // must have hit cancel if filepath is null
        } );
    }
    

    Meanwhile in Java:

    public void showFileDialog( JavascriptFunction someJavascriptFunction ) {
        SwingUtilities.invokeLater( new Runnable() {
            public void run() {
                JFileChooserDialog chooser = new JFileChooser();
                ...
                int option = chooser.showOpenDialog( parent );
    
                someJavascriptFunction.invoke( option == JFileChooser.APPROVE_OPTION ? 
                                               chooser.getSelectedFile().getAbsolutePath() : 
                                               null );
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pop up a quick dialog for the user to select one
I have jquery pop form to upload a file, after on submit (the page
I need to have a pop-up dialog like the Color Dialog or Save Dialog
I need to show a folder dialog box so the user can select a
I have added an open file dialog box to my client application so that
I'm using Response.AddHeader(Content-Disposition, attachment; filename= + Server.HtmlEncode(FileName)); to pop a 'open/save file' dialog for
I have a need to create a small pop up information box when a
I need to download a file with french file name for example mé.txt..I have
I have a page that produces a PDF and automatically downloads the file. I
In my wpf application I need a button which lets me select a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.