diff --git a/src/main/java/ai/nets/samj/communication/model/SAMModel.java b/src/main/java/ai/nets/samj/communication/model/SAMModel.java index 89fb3c6..dabef2a 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAMModel.java +++ b/src/main/java/ai/nets/samj/communication/model/SAMModel.java @@ -313,6 +313,14 @@ public void closeProcess() { samj.close(); samj = null; } + + /** + * Check whether the model is loaded or not + * @return whether the model is loaded or not + */ + public boolean isLoaded() { + return samj != null; + } public String persistEncoding() throws IOException, InterruptedException { try { diff --git a/src/main/java/ai/nets/samj/gui/MainGUI.java b/src/main/java/ai/nets/samj/gui/MainGUI.java index 404d4bb..3ac4849 100644 --- a/src/main/java/ai/nets/samj/gui/MainGUI.java +++ b/src/main/java/ai/nets/samj/gui/MainGUI.java @@ -642,7 +642,8 @@ public void validPromptChosen(boolean isValid) { CardLayout lyt = (CardLayout) cardPanel1_2.getLayout(); lyt.show(cardPanel1_2, INVISIBLE_STR); isValidPrompt = true; - MainGUI.this.chkInstant.setEnabled(true); + if (cmbModels.getSelectedModel().isLoaded()) + MainGUI.this.chkInstant.setEnabled(true); } else if (!isValid && isValidPrompt) { CardLayout lyt = (CardLayout) cardPanel1_2.getLayout(); lyt.show(cardPanel1_2, VISIBLE_STR); diff --git a/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java b/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java index 8461f8d..c527151 100644 --- a/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java +++ b/src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java @@ -337,6 +337,9 @@ private void stopLoadingAnimation() { isLoading = false; if (loadingAnimationThread != null && loadingAnimationThread.isAlive()) { loadingAnimationThread.interrupt(); + try { + loadingAnimationThread.join(); + } catch (InterruptedException e) {} } }