classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: JOptionPane fixlet


From: Roman Kennke
Subject: [cp-patches] FYI: JOptionPane fixlet
Date: Wed, 20 Jul 2005 14:51:17 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

Hi fixed JOptionPane.createInternalFrame(). It used to do what the spec says, that is look up the nearest JDesktopPane in the specified parent component. The JDK behaves against the specs and looks up the nearest JLayeredPane instead, which is reasonable. So do we now.

This makes the JOptionPane.showInternalXXX() methods somewhat working :-D


2005-07-20  Roman Kennke  <address@hidden>

       * javax/swing/JOptionPane.java
       (createInternalFrame): Look up the nearest JLayeredPane instead
       of JDesktopPane. This is in contrast to the specs but what the JDK
       does and what makes sense.

/Roman

Index: javax/swing/JOptionPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JOptionPane.java,v
retrieving revision 1.13
diff -u -r1.13 JOptionPane.java
--- javax/swing/JOptionPane.java        2 Jul 2005 20:32:48 -0000       1.13
+++ javax/swing/JOptionPane.java        20 Jul 2005 12:48:36 -0000
@@ -384,8 +384,8 @@
   }
 
   /**
-   * This method creates a new JInternalFrame that is in the JDesktopPane
-   * which contains the parentComponent given. If no suitable JDesktopPane
+   * This method creates a new JInternalFrame that is in the JLayeredPane
+   * which contains the parentComponent given. If no suitable JLayeredPane
    * can be found from the parentComponent given, a RuntimeException will be
    * thrown.
    *
@@ -395,14 +395,22 @@
    * @return A new JInternalFrame based on the JOptionPane configuration.
    *
    * @throws RuntimeException If no suitable JDesktopPane is found.
+   *
+   * @specnote The specification says that the internal frame is placed
+   *           in the nearest <code>JDesktopPane</code> that is found in
+   *           <code>parent</code>'s ancestors. The behaviour of the JDK
+   *           is that it actually looks up the nearest
+   *           <code>JLayeredPane</code> in <code>parent</code>'s ancestors.
+   *           So do we.
    */
   public JInternalFrame createInternalFrame(Component parentComponent,
                                             String title)
                                      throws RuntimeException
   {
-    JDesktopPane toUse = getDesktopPaneForComponent(parentComponent);
+    JLayeredPane toUse = JLayeredPane.getLayeredPaneAbove(parentComponent);
     if (toUse == null)
-      throw new RuntimeException("parentComponent does not have a valid 
parent");
+      throw new RuntimeException
+        ("parentComponent does not have a valid parent");
 
     JInternalFrame frame = new JInternalFrame(title);
 
@@ -411,9 +419,8 @@
 
     frame.setClosable(true);
     toUse.add(frame);
-
     // FIXME: JLayeredPane broken? See bug # 16576
-    // frame.setLayer(JLayeredPane.MODAL_LAYER);
+    frame.setLayer(JLayeredPane.MODAL_LAYER);
     return frame;
   }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]