diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesPanel.java b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesPanel.java index db5f5c1990..81fac1ebd6 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/contentviewer/OtherOccurrencesPanel.java @@ -49,7 +49,6 @@ import javax.swing.SwingWorker; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; @@ -87,6 +86,8 @@ public final class OtherOccurrencesPanel extends javax.swing.JPanel { private SwingWorker worker; + // Initializing the JFileChooser in a thread to prevent a block on the EDT + // see https://stackoverflow.com/questions/49792375/jfilechooser-is-very-slow-when-using-windows-look-and-feel private final FutureTask futureFileChooser = new FutureTask<>(JFileChooser::new); private JFileChooser CSVFileChooser; @@ -254,11 +255,14 @@ public final class OtherOccurrencesPanel extends javax.swing.JPanel { if (casesTableModel.getRowCount() > 0) { if(CSVFileChooser == null) { - try { + try{ CSVFileChooser = futureFileChooser.get(); } catch (InterruptedException | ExecutionException ex) { - Exceptions.printStackTrace(ex); - } + // If something happened with the thread try and + // initalized the chooser now + logger.log(Level.WARNING, "A failure occurred in the JFileChooser background thread"); + CSVFileChooser = new JFileChooser(); + } } Calendar now = Calendar.getInstance(); diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java index 591bed7ff3..177c397c78 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/MediaViewImagePanel.java @@ -72,7 +72,6 @@ import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import org.apache.commons.io.FilenameUtils; import org.controlsfx.control.MaskerPane; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.actions.GetTagNameAndCommentDialog; import org.sleuthkit.autopsy.actions.GetTagNameAndCommentDialog.TagNameAndComment; @@ -194,6 +193,8 @@ class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPan private Task readImageFileTask; private volatile ImageTransforms imageTransforms; + // Initializing the JFileChooser in a thread to prevent a block on the EDT + // see https://stackoverflow.com/questions/49792375/jfilechooser-is-very-slow-when-using-windows-look-and-feel private final FutureTask futureFileChooser = new FutureTask<>(JFileChooser::new); /** @@ -1050,7 +1051,10 @@ class MediaViewImagePanel extends JPanel implements MediaFileViewer.MediaViewPan try { exportChooser = futureFileChooser.get(); } catch (InterruptedException | ExecutionException ex) { - Exceptions.printStackTrace(ex); + // If something happened with the thread try and + // initalized the chooser now + logger.log(Level.WARNING, "A failure occurred in the JFileChooser background thread"); + exportChooser = new JFileChooser(); } }