diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c700c2..ad4f38bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ FlatLaf Change Log ================== +## 3.5-SNAPSHOT + +#### Incompatibilities + +- ProgressBar: Log warning (including stack trace) when uninstalling + indeterminate progress bar UI or using JProgressBar.setIndeterminate(false) + not on AWT thread, because this may throw NPE in FlatProgressBarUI.paint(). + (issues #841 and #830) + + ## 3.4.1 #### Fixed bugs diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java index 58d02190..6e22376d 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatProgressBarUI.java @@ -18,6 +18,7 @@ package com.formdev.flatlaf.ui; import static com.formdev.flatlaf.FlatClientProperties.*; import java.awt.Dimension; +import java.awt.EventQueue; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; @@ -86,6 +87,17 @@ public class FlatProgressBarUI installStyle(); } + @Override + public void uninstallUI( JComponent c ) { + if( !EventQueue.isDispatchThread() && progressBar.isIndeterminate() ) { + LoggingFacade.INSTANCE.logSevere( + "FlatLaf: Uninstalling indeterminate progress bar UI not on AWT thread may throw NPE in FlatProgressBarUI.paint(). Use SwingUtilities.invokeLater().", + new IllegalStateException() ); + } + + super.uninstallUI( c ); + } + @Override protected void installDefaults() { super.installDefaults(); @@ -110,6 +122,14 @@ public class FlatProgressBarUI propertyChangeListener = e -> { switch( e.getPropertyName() ) { + case "indeterminate": + if( !EventQueue.isDispatchThread() && !progressBar.isIndeterminate() ) { + LoggingFacade.INSTANCE.logSevere( + "FlatLaf: Using JProgressBar.setIndeterminate(false) not on AWT thread may throw NPE in FlatProgressBarUI.paint(). Use SwingUtilities.invokeLater().", + new IllegalStateException() ); + } + break; + case PROGRESS_BAR_LARGE_HEIGHT: case PROGRESS_BAR_SQUARE: progressBar.revalidate();