mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 14:37:13 -06:00
TabbedPane: fixed NPE when creating/modifying in another thread (issue #299)
This commit is contained in:
@@ -11,6 +11,7 @@ FlatLaf Change Log
|
|||||||
when window is maximized. (issue #296)
|
when window is maximized. (issue #296)
|
||||||
- Button and ToggleButton: Do not paint background of disabled (and unselected)
|
- Button and ToggleButton: Do not paint background of disabled (and unselected)
|
||||||
toolBar buttons. (issue #292; regression since fixing #112)
|
toolBar buttons. (issue #292; regression since fixing #112)
|
||||||
|
- TabbedPane: Fixed NPE when creating/modifying in another thread. (issue #299)
|
||||||
- Fixed crash when running in Webswing. (issue #290)
|
- Fixed crash when running in Webswing. (issue #290)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -722,6 +722,13 @@ public class FlatTabbedPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Insets getRealTabAreaInsets( int tabPlacement ) {
|
protected Insets getRealTabAreaInsets( int tabPlacement ) {
|
||||||
|
// this is to avoid potential NPE in ensureSelectedTabIsVisible()
|
||||||
|
// (see https://github.com/JFormDesigner/FlatLaf/issues/299)
|
||||||
|
// but now should actually never occur because added more checks to
|
||||||
|
// ensureSelectedTabIsVisibleLater() and ensureSelectedTabIsVisible()
|
||||||
|
if( tabAreaInsets == null )
|
||||||
|
tabAreaInsets = new Insets( 0, 0, 0, 0 );
|
||||||
|
|
||||||
Insets currentTabAreaInsets = super.getTabAreaInsets( tabPlacement );
|
Insets currentTabAreaInsets = super.getTabAreaInsets( tabPlacement );
|
||||||
Insets insets = (Insets) currentTabAreaInsets.clone();
|
Insets insets = (Insets) currentTabAreaInsets.clone();
|
||||||
|
|
||||||
@@ -1386,13 +1393,18 @@ public class FlatTabbedPaneUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void ensureSelectedTabIsVisibleLater() {
|
protected void ensureSelectedTabIsVisibleLater() {
|
||||||
|
// do nothing if not yet displayable or if not invoked from dispatch thread,
|
||||||
|
// which may be the case when creating/modifying in another thread
|
||||||
|
if( !tabPane.isDisplayable() || !EventQueue.isDispatchThread() )
|
||||||
|
return;
|
||||||
|
|
||||||
EventQueue.invokeLater( () -> {
|
EventQueue.invokeLater( () -> {
|
||||||
ensureSelectedTabIsVisible();
|
ensureSelectedTabIsVisible();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ensureSelectedTabIsVisible() {
|
protected void ensureSelectedTabIsVisible() {
|
||||||
if( tabPane == null || tabViewport == null )
|
if( tabPane == null || tabViewport == null || !tabPane.isDisplayable() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ensureCurrentLayout();
|
ensureCurrentLayout();
|
||||||
|
|||||||
Reference in New Issue
Block a user