mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 06:27: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)
|
||||
- Button and ToggleButton: Do not paint background of disabled (and unselected)
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -722,6 +722,13 @@ public class FlatTabbedPaneUI
|
||||
}
|
||||
|
||||
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 insets = (Insets) currentTabAreaInsets.clone();
|
||||
|
||||
@@ -1386,13 +1393,18 @@ public class FlatTabbedPaneUI
|
||||
}
|
||||
|
||||
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( () -> {
|
||||
ensureSelectedTabIsVisible();
|
||||
} );
|
||||
}
|
||||
|
||||
protected void ensureSelectedTabIsVisible() {
|
||||
if( tabPane == null || tabViewport == null )
|
||||
if( tabPane == null || tabViewport == null || !tabPane.isDisplayable() )
|
||||
return;
|
||||
|
||||
ensureCurrentLayout();
|
||||
|
||||
Reference in New Issue
Block a user