From 3d8c535ffab323aa244c6b49bfe1ec9ed365742b Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 25 Sep 2021 19:34:46 +0200 Subject: [PATCH] Styling: catch runtime exceptions while applying styles (and log them) to avoid that wrong/invalid styles could result in "damaged" UI --- .../src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java | 7 ++++++- .../com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java | 7 ++++++- .../java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java | 7 ++++++- .../src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java | 7 ++++++- .../src/main/java/com/formdev/flatlaf/ui/FlatListUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java | 7 ++++++- .../src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java | 7 ++++++- .../java/com/formdev/flatlaf/ui/FlatProgressBarUI.java | 7 ++++++- .../com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java | 7 ++++++- .../java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatScrollPaneUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java | 7 ++++++- .../src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java | 7 ++++++- .../java/com/formdev/flatlaf/ui/FlatStylingSupport.java | 4 +++- .../main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java | 7 ++++++- .../java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java | 7 ++++++- .../src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatTextAreaUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatTextPaneUI.java | 7 ++++++- .../com/formdev/flatlaf/ui/FlatToolBarSeparatorUI.java | 7 ++++++- .../main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java | 7 ++++++- .../src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java | 7 ++++++- 30 files changed, 177 insertions(+), 30 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java index a29c4626..79f330fe 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java @@ -51,6 +51,7 @@ import com.formdev.flatlaf.icons.FlatHelpButtonIcon; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -270,7 +271,11 @@ public class FlatButtonUI /** @since 2 */ protected void installStyle( AbstractButton b ) { - applyStyle( b, FlatStylingSupport.getResolvedStyle( b, getStyleType() ) ); + try { + applyStyle( b, FlatStylingSupport.getResolvedStyle( b, getStyleType() ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java index b78ca31d..8c0ab140 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCheckBoxMenuItemUI.java @@ -28,6 +28,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JCheckBoxMenuItem}. @@ -103,7 +104,11 @@ public class FlatCheckBoxMenuItemUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "CheckBoxMenuItem" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "CheckBoxMenuItem" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java index 25f086bf..9cb4e22e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java @@ -72,6 +72,7 @@ import javax.swing.plaf.basic.ComboPopup; import javax.swing.text.JTextComponent; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.SystemInfo; /** @@ -452,7 +453,11 @@ public class FlatComboBoxUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( comboBox, "ComboBox" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( comboBox, "ComboBox" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java index 6c9cb714..b5386c49 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java @@ -35,6 +35,7 @@ import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JEditorPane}. @@ -174,7 +175,11 @@ public class FlatEditorPaneUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), "EditorPane" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), "EditorPane" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java index 32460cda..d000f57d 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatInternalFrameUI.java @@ -38,6 +38,7 @@ import javax.swing.plaf.basic.BasicInternalFrameUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableBorder; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JInternalFrame}. @@ -154,7 +155,11 @@ public class FlatInternalFrameUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( frame, "InternalFrame" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( frame, "InternalFrame" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java index 2c16494a..b23a90c6 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatLabelUI.java @@ -39,6 +39,7 @@ import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -133,7 +134,11 @@ public class FlatLabelUI /** @since 2 */ protected void installStyle( JLabel c ) { - applyStyle( c, FlatStylingSupport.getResolvedStyle( c, "Label" ) ); + try { + applyStyle( c, FlatStylingSupport.getResolvedStyle( c, "Label" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java index 956c6b76..cd0ab3f5 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java @@ -30,6 +30,7 @@ import javax.swing.plaf.basic.BasicListUI; import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JList}. @@ -162,7 +163,11 @@ public class FlatListUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( list, "List" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( list, "List" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java index a0e5280a..b2ffd44f 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuBarUI.java @@ -42,6 +42,7 @@ import javax.swing.plaf.basic.BasicMenuBarUI; import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.SystemInfo; /** @@ -138,7 +139,11 @@ public class FlatMenuBarUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( menuBar, "MenuBar" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( menuBar, "MenuBar" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java index 0b7b9516..785c220b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemUI.java @@ -29,6 +29,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicMenuItemUI; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JMenuItem}. @@ -104,7 +105,11 @@ public class FlatMenuItemUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "MenuItem" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "MenuItem" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java index 009c505a..37d819cb 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuUI.java @@ -38,6 +38,7 @@ import javax.swing.plaf.MenuBarUI; import javax.swing.plaf.basic.BasicMenuUI; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JMenu}. @@ -150,7 +151,11 @@ public class FlatMenuUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "Menu" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "Menu" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java index 1b7c1b12..cb3d6169 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java @@ -23,6 +23,7 @@ import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicPopupMenuUI; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JPopupMenu}. @@ -81,7 +82,11 @@ public class FlatPopupMenuUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( popupMenu, "PopupMenu" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( popupMenu, "PopupMenu" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ 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 9af3a538..7a13421b 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 @@ -35,6 +35,7 @@ import javax.swing.plaf.basic.BasicProgressBarUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -132,7 +133,11 @@ public class FlatProgressBarUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( progressBar, "ProgressBar" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( progressBar, "ProgressBar" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java index 5cab968e..efb99f58 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonMenuItemUI.java @@ -28,6 +28,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JRadioButtonMenuItem}. @@ -103,7 +104,11 @@ public class FlatRadioButtonMenuItemUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "RadioButtonMenuItem" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( menuItem, "RadioButtonMenuItem" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java index 75be18d9..409a2e97 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRadioButtonUI.java @@ -39,6 +39,7 @@ import com.formdev.flatlaf.icons.FlatCheckBoxIcon; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -149,7 +150,11 @@ public class FlatRadioButtonUI /** @since 2 */ protected void installStyle( AbstractButton b ) { - applyStyle( b, FlatStylingSupport.getResolvedStyle( b, getStyleType() ) ); + try { + applyStyle( b, FlatStylingSupport.getResolvedStyle( b, getStyleType() ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java index f2f32e40..d05ff897 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java @@ -39,6 +39,7 @@ import javax.swing.plaf.basic.BasicScrollBarUI; import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -223,7 +224,11 @@ public class FlatScrollBarUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( scrollbar, "ScrollBar" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( scrollbar, "ScrollBar" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollPaneUI.java index 8adb6c6a..4b52cd62 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollPaneUI.java @@ -49,6 +49,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicScrollPaneUI; import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JScrollPane}. @@ -304,7 +305,11 @@ public class FlatScrollPaneUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( scrollpane, "ScrollPane" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( scrollpane, "ScrollPane" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java index b002b0e5..e418c23e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSeparatorUI.java @@ -30,6 +30,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSeparatorUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JSeparator}. @@ -134,7 +135,11 @@ public class FlatSeparatorUI /** @since 2 */ protected void installStyle( JSeparator s ) { - applyStyle( s, FlatStylingSupport.getResolvedStyle( s, getStyleType() ) ); + try { + applyStyle( s, FlatStylingSupport.getResolvedStyle( s, getStyleType() ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java index bb65102b..84f86b16 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSliderUI.java @@ -42,6 +42,7 @@ import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.Graphics2DProxy; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -194,7 +195,11 @@ public class FlatSliderUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( slider, "Slider" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( slider, "Slider" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java index 8819b32a..42c815d6 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSpinnerUI.java @@ -47,6 +47,7 @@ import javax.swing.plaf.basic.BasicSpinnerUI; import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JSpinner}. @@ -192,7 +193,11 @@ public class FlatSpinnerUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( spinner, "Spinner" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( spinner, "Spinner" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java index 6d537a72..d2c5c989 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatSplitPaneUI.java @@ -37,6 +37,7 @@ import javax.swing.plaf.basic.BasicSplitPaneUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -139,7 +140,11 @@ public class FlatSplitPaneUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( splitPane, "SplitPane" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( splitPane, "SplitPane" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java index 58774c0c..de2b9d5c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java @@ -506,7 +506,9 @@ public class FlatStylingSupport * @throws UnknownStyleException if object does not have a annotated field with given name * @throws IllegalArgumentException if value type does not fit to expected type */ - public static Object applyToAnnotatedObjectOrComponent( Object obj, Object comp, String key, Object value ) { + public static Object applyToAnnotatedObjectOrComponent( Object obj, Object comp, String key, Object value ) + throws UnknownStyleException, IllegalArgumentException + { try { return applyToAnnotatedObject( obj, key, value ); } catch( UnknownStyleException ex ) { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java index 67d900be..75afa3e0 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTabbedPaneUI.java @@ -93,6 +93,7 @@ import com.formdev.flatlaf.ui.FlatStylingSupport.UnknownStyleException; import com.formdev.flatlaf.util.Animator; import com.formdev.flatlaf.util.CubicBezierEasing; import com.formdev.flatlaf.util.JavaCompatibility; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.StringUtils; import com.formdev.flatlaf.util.UIScale; @@ -574,7 +575,11 @@ public class FlatTabbedPaneUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( tabPane, "TabbedPane" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( tabPane, "TabbedPane" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java index 0c0904b5..8be68cbf 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java @@ -43,6 +43,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -142,7 +143,11 @@ public class FlatTableHeaderUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( header, "TableHeader" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( header, "TableHeader" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java index b3df21f3..930b04b8 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java @@ -41,6 +41,7 @@ import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.Graphics2DProxy; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.UIScale; @@ -238,7 +239,11 @@ public class FlatTableUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( table, "Table" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( table, "Table" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextAreaUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextAreaUI.java index 244757e3..569ab1ab 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextAreaUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextAreaUI.java @@ -32,6 +32,7 @@ import javax.swing.plaf.basic.BasicTextAreaUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JTextArea}. @@ -148,7 +149,11 @@ public class FlatTextAreaUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), "TextArea" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), "TextArea" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java index 8dc04234..6814e7f8 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java @@ -47,6 +47,7 @@ import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.HiDPIUtils; import com.formdev.flatlaf.util.JavaCompatibility; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JTextField}. @@ -229,7 +230,11 @@ public class FlatTextFieldUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), getStyleType() ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), getStyleType() ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextPaneUI.java index 5aa3b6a1..7d43760b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextPaneUI.java @@ -32,6 +32,7 @@ import javax.swing.plaf.basic.BasicTextPaneUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.HiDPIUtils; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JTextPane}. @@ -156,7 +157,11 @@ public class FlatTextPaneUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), "TextPane" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( getComponent(), "TextPane" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarSeparatorUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarSeparatorUI.java index 865fe3a2..28e3508a 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarSeparatorUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarSeparatorUI.java @@ -33,6 +33,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicToolBarSeparatorUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JToolBar.Separator}. @@ -130,7 +131,11 @@ public class FlatToolBarSeparatorUI /** @since 2 */ protected void installStyle( JSeparator s ) { - applyStyle( FlatStylingSupport.getResolvedStyle( s, "ToolBarSeparator" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( s, "ToolBarSeparator" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java index 291bd0f4..a2f100ac 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToolBarUI.java @@ -31,6 +31,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicToolBarUI; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; /** * Provides the Flat LaF UI delegate for {@link javax.swing.JToolBar}. @@ -138,7 +139,11 @@ public class FlatToolBarUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( toolBar, "ToolBar" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( toolBar, "ToolBar" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */ diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java index 531b732e..03c63d3b 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java @@ -42,6 +42,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreePath; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; +import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.UIScale; /** @@ -312,7 +313,11 @@ public class FlatTreeUI /** @since 2 */ protected void installStyle() { - applyStyle( FlatStylingSupport.getResolvedStyle( tree, "Tree" ) ); + try { + applyStyle( FlatStylingSupport.getResolvedStyle( tree, "Tree" ) ); + } catch( RuntimeException ex ) { + LoggingFacade.INSTANCE.logSevere( null, ex ); + } } /** @since 2 */