Skip to content

Both SystemFileChooser and Swing FileChooser open when called from event dispatching thread on Windows #1078

@Kamik423

Description

@Kamik423

For macOS reasons, I had the following code (or at least something similar) in the main method.

Timer timer =
    new Timer(
        10,
        ae -> {
          if (!MyApp.hasOpenedAnyFileYet) {
              SystemFileChooser fileChooser = new SystemFileChooser();
              fileChooser.addChoosableFileFilter(...);
              fileChooser.setFileFilter(...);
              if (fileChooser.showOpenDialog(null) == SystemFileChooser.APPROVE_OPTION) { ... }
        }});
timer.setRepeats(false);
timer.start();

On macOS, this does indeed work fine.
On Windows, this results in both a SystemFileChooser and a FlatLaf/Swing one opening.

I now circumvented this issue by not using the timer mechanism on Windows.
However, it does seem like a bug, so I wanted to report it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions