Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.

Using JxBrowser DialogHandler API you can handle situation when web page needs to display File Open dialog (e.g. when user clicks File Input element on a web form). Using this API you can display your own File Open dialog or suppress the dialog at all and provide path to a file program.

Note: By default JxBrowser displays standard Java Swing/JavaFX File Open dialog.

The following sample demonstrates how to display your File Open dialog using Java Swing API: 

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.CloseStatus;
import com.teamdev.jxbrowser.chromium.FileChooserMode;
import com.teamdev.jxbrowser.chromium.FileChooserParams;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import com.teamdev.jxbrowser.chromium.swing.DefaultDialogHandler;
import java.awt.BorderLayout;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.atomic.AtomicReference;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

 * The sample demonstrates how to register your DialogHandler and
 * override the functionality that displays file chooser when
 * user uploads file using INPUT TYPE="file" HTML element on a web page.
public class FileUploadSample {
    public static void main(String[] args) {
        Browser browser = new Browser();
        final BrowserView view = new BrowserView(browser);

        JFrame frame = new JFrame();
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(700, 500);

        browser.setDialogHandler(new DefaultDialogHandler(view) {
            public CloseStatus onFileChooser(final FileChooserParams params) {
                final AtomicReference<CloseStatus> result = new AtomicReference<CloseStatus>(

                try {
                    SwingUtilities.invokeAndWait(new Runnable() {
                        public void run() {
                            if (params.getMode() == FileChooserMode.Open) {
                                JFileChooser fileChooser = new JFileChooser();
                                if (fileChooser.showOpenDialog(view)
                                        == JFileChooser.APPROVE_OPTION) {
                                    File selectedFile = fileChooser.getSelectedFile();
                } catch (InterruptedException e) {
                } catch (InvocationTargetException e) {

                return result.get();

Click Choose File button to display File Open dialog and select file to upload:

Swing File Open dialog