8062525: JInternalFrame can't show correctly with the specical option "-esa -ea -Xcheck:jni -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel".
authorssadetsky
Thu, 03 Nov 2016 12:13:59 +0300
changeset 42192 35a00ea5c65d
parent 42191 e5ba7d74e3c6
child 42193 f7550ec880cf
8062525: JInternalFrame can't show correctly with the specical option "-esa -ea -Xcheck:jni -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel". Reviewed-by: serb
jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	Thu Nov 03 11:51:31 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	Thu Nov 03 12:13:59 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType;
 
 import javax.swing.plaf.ColorUIResource;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
 import javax.swing.plaf.synth.*;
 
 import java.awt.*;
@@ -40,7 +41,6 @@
 import java.util.*;
 
 import javax.swing.*;
-import javax.swing.border.*;
 
 import javax.xml.parsers.*;
 import org.xml.sax.SAXException;
@@ -226,12 +226,8 @@
         JComponent titlePane = (JComponent)button.getParent();
         Container titlePaneParent = titlePane.getParent();
 
-        JInternalFrame jif;
-        if (titlePaneParent instanceof JInternalFrame) {
-            jif = (JInternalFrame)titlePaneParent;
-        } else if (titlePaneParent instanceof JInternalFrame.JDesktopIcon) {
-            jif = ((JInternalFrame.JDesktopIcon)titlePaneParent).getInternalFrame();
-        } else {
+        JInternalFrame jif = findInternalFrame(titlePaneParent);
+        if (jif == null) {
             return;
         }
 
@@ -332,6 +328,19 @@
         }
     }
 
+    JInternalFrame findInternalFrame(Component comp) {
+        if (comp.getParent() instanceof BasicInternalFrameTitlePane) {
+            comp = comp.getParent();
+        }
+        if (comp instanceof JInternalFrame) {
+            return  (JInternalFrame)comp;
+        } else if (comp instanceof JInternalFrame.JDesktopIcon) {
+            return ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
+        }
+        assert false : "cannot find the internal frame";
+        return null;
+    }
+
     void paintFrameBorder(SynthContext context, Graphics g, int x0, int y0, int width, int height) {
         updateFrameGeometry(context);
 
@@ -343,13 +352,8 @@
             return;
         }
 
-        JInternalFrame jif = null;
-        if (comp instanceof JInternalFrame) {
-            jif = (JInternalFrame)comp;
-        } else if (comp instanceof JInternalFrame.JDesktopIcon) {
-            jif = ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
-        } else {
-            assert false : "component is not JInternalFrame or JInternalFrame.JDesktopIcon";
+        JInternalFrame jif = findInternalFrame(comp);
+        if (jif == null) {
             return;
         }
 
@@ -1467,13 +1471,8 @@
         JComponent comp = context.getComponent();
         JComponent titlePane = findChild(comp, "InternalFrame.northPane");
 
-        JInternalFrame jif = null;
-        if (comp instanceof JInternalFrame) {
-            jif = (JInternalFrame)comp;
-        } else if (comp instanceof JInternalFrame.JDesktopIcon) {
-            jif = ((JInternalFrame.JDesktopIcon)comp).getInternalFrame();
-        } else {
-            assert false : "component is not JInternalFrame or JInternalFrame.JDesktopIcon";
+        JInternalFrame jif = findInternalFrame(comp);
+        if (jif == null) {
             return;
         }