mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
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)
This commit is contained in:
10
CHANGELOG.md
10
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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user