Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096876

Serious threading issue in sample code in File Chooser tutorial

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7-pool, 8, 8u20, 9
    • Fix Version/s: 8u20
    • Component/s: docs
    • Labels:
      None

      Description

      The following page:

      http://docs.oracle.com/javafx/2/ui_controls/file-chooser.htm

      contains a sample application that calls AWT APIs on the FX Application Thread. Specifically, the Desktop.open() method is called from an action event handler. This threading pattern is wrong and shouldn't be advertised because it causes the application to freeze on certain platforms (e.g. see RT-31468).

      The correct pattern is to wrap the call to any AWT APIs in a runnable and submit it for execution via java.awt.EventQueue.invokeLater():

      void fxEventHandler() {
         EQ.invokeLater(() -> {
            Desktop.open(...);
         });
      }

        Attachments

          Activity

            People

            Assignee:
            shommel Scott Hommel (Inactive)
            Reporter:
            anthony Anthony Petrov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved:
              Imported: