changeset 52912:40279c4862ec

8213843: Changing L&F from Nimbus to Window L&F causes NPE in SwingSet2 8213121: javax/swing/GraphicsConfigNotifier/StalePreferredSize.java fails on mac10.13 Reviewed-by: serb
author psadhukhan
date Tue, 27 Nov 2018 10:45:54 +0530
parents fe70e9638c42
children 0d757a37896c
files src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java test/jdk/ProblemList.txt test/jdk/javax/swing/GraphicsConfigNotifier/StalePreferredSize.java
diffstat 3 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Mon Nov 26 10:49:53 2018 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Tue Nov 27 10:45:54 2018 +0530
@@ -55,14 +55,7 @@
      * @return the UI object
      */
     public static ComponentUI createUI(JComponent c) {
-        AppContext appContext = AppContext.getAppContext();
-        SynthButtonUI synthButtonUI =
-                (SynthButtonUI) appContext.get(SYNTH_BUTTON_UI_KEY);
-        if (synthButtonUI == null) {
-            synthButtonUI = new SynthButtonUI();
-            appContext.put(SYNTH_BUTTON_UI_KEY, synthButtonUI);
-        }
-        return synthButtonUI;
+        return new SynthButtonUI();
     }
 
     /**
@@ -216,9 +209,15 @@
 
         // layout the text and icon
         SynthContext context = getContext(b);
+        SynthStyle style;
+        if (context.getStyle() != null) {
+            style = context.getStyle();
+        } else {
+            style = SynthLookAndFeel.updateStyle(context, this);
+        }
         FontMetrics fm = context.getComponent().getFontMetrics(
-                               context.getStyle().getFont(context));
-        context.getStyle().getGraphicsUtils(context).layoutText(
+                               style.getFont(context));
+        style.getGraphicsUtils(context).layoutText(
             context, fm, b.getText(), b.getIcon(),
             b.getHorizontalAlignment(), b.getVerticalAlignment(),
             b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
--- a/test/jdk/ProblemList.txt	Mon Nov 26 10:49:53 2018 +0530
+++ b/test/jdk/ProblemList.txt	Tue Nov 27 10:45:54 2018 +0530
@@ -815,7 +815,6 @@
 javax/swing/JPopupMenu/6583251/bug6583251.java 8213564 linux-all
 javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765  macosx-all,linux-all
 javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all
-javax/swing/GraphicsConfigNotifier/StalePreferredSize.java 8213121 macosx-all,linux-all
 javax/swing/JButton/4368790/bug4368790.java 8213123 macosx-all
 javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
 javax/swing/JTable/6263446/bug6263446.java 8169959 macosx-all
--- a/test/jdk/javax/swing/GraphicsConfigNotifier/StalePreferredSize.java	Mon Nov 26 10:49:53 2018 +0530
+++ b/test/jdk/javax/swing/GraphicsConfigNotifier/StalePreferredSize.java	Tue Nov 27 10:45:54 2018 +0530
@@ -59,7 +59,7 @@
 /**
  * @test
  * @key headful
- * @bug 8201552
+ * @bug 8201552 8213843
  * @summary Initial layout of the component should use correct graphics config.
  *          It is checked by SwingUtilities.updateComponentTreeUI(), if layout
  *          was correct the call to updateComponentTreeUI() will be no-op.