From: Jim Procter Date: Tue, 21 May 2024 17:15:11 +0000 (+0100) Subject: JAL-4159 sometimes the progress bar may not be available - null check X-Git-Tag: Release_2_11_4_0~31^2~17 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8c6b6a42a800bd82ebb40ebc58d3c463d2e97a9c;p=jalview.git JAL-4159 sometimes the progress bar may not be available - null check --- diff --git a/src/jalview/gui/ProgressBar.java b/src/jalview/gui/ProgressBar.java index 8189313..73cd496 100644 --- a/src/jalview/gui/ProgressBar.java +++ b/src/jalview/gui/ProgressBar.java @@ -24,6 +24,7 @@ import jalview.util.MessageManager; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -272,10 +273,17 @@ public class ProgressBar implements IProgressIndicator */ public JProgressBar getProgressBar(long id) { - for (Component component : progressBars.get(id).getComponents()) - { + Container progBar = progressBars.get(id); + if (progBar==null || progBar.getComponentCount()==0) + { + return null; + } + for (Component component : progBar.getComponents()) + { if (component.getClass().equals(JProgressBar.class)) - return (JProgressBar) component; + { + return (JProgressBar) component; + } } return null; }