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

Serious threading issue in sample code in File Chooser tutorial

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8u20
    • 7-pool, 8, 8u20, 9
    • docs
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported: