classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: JOptionPane fix


From: Roman Kennke
Subject: [cp-patches] FYI: JOptionPane fix
Date: Thu, 21 Jul 2005 13:58:24 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

I fixed the createInternalFrame method so that it actually brings the InternalFrame up in its parent. This was done in startModal() before, which is not correct.

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

       * javax/swing/JOptionPane.java
       (createInternalFrame): Look for a JDesktopPane first, then
       look for a JLayeredPane as fallback. Set this JOptionPane as
       contentPane for the found JDesktopPane. Make the InternalFrame
       visible and appropriatly sized here.
       (showInternalConfirmDialog): ALL VARIANTS OF THIS METHOD:
       Adjusted call to startModel to only take one parameter.
       (showInternalInputDialog): ALL VARIANTS OF THIS METHOD:
       Adjusted call to startModel to only take one parameter.
       (showInternalMessageDialog): ALL VARIANTS OF THIS METHOD:
       Adjusted call to startModel to only take one parameter.
       (showInternalOptionDialog): ALL VARIANTS OF THIS METHOD:
       Adjusted call to startModel to only take one parameter.
       (startModal): Now only takes one parameter. This method does no
       longer add the JOptionPane to the contentPane of the InternalFrame,
       set the size and make the InternalFrame visible. This is done in
       createInternalFrame.

/Roman

Index: javax/swing/JOptionPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JOptionPane.java,v
retrieving revision 1.14
diff -u -r1.14 JOptionPane.java
--- javax/swing/JOptionPane.java        20 Jul 2005 12:49:06 -0000      1.14
+++ javax/swing/JOptionPane.java        21 Jul 2005 11:47:08 -0000
@@ -407,7 +407,12 @@
                                             String title)
                                      throws RuntimeException
   {
-    JLayeredPane toUse = JLayeredPane.getLayeredPaneAbove(parentComponent);
+    // Try to find a JDesktopPane.
+    JLayeredPane toUse = getDesktopPaneForComponent(parentComponent);
+    // If we don't have a JDesktopPane, we try to find a JLayeredPane.
+    if (toUse == null)
+      toUse = JLayeredPane.getLayeredPaneAbove(parentComponent);
+    // If this still fails, we throw a RuntimeException.
     if (toUse == null)
       throw new RuntimeException
         ("parentComponent does not have a valid parent");
@@ -417,10 +422,15 @@
     inputValue = UNINITIALIZED_VALUE;
     value = UNINITIALIZED_VALUE;
 
+    frame.setContentPane(this);
     frame.setClosable(true);
+
     toUse.add(frame);
-    // FIXME: JLayeredPane broken? See bug # 16576
     frame.setLayer(JLayeredPane.MODAL_LAYER);
+
+    frame.pack();
+    frame.setVisible(true);
+
     return frame;
   }
 
@@ -1109,7 +1119,7 @@
     JOptionPane pane = new JOptionPane(message);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return ((Integer) pane.getValue()).intValue();
   }
@@ -1134,7 +1144,7 @@
     JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, optionType);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return ((Integer) pane.getValue()).intValue();
   }
@@ -1160,7 +1170,7 @@
     JOptionPane pane = new JOptionPane(message, messageType, optionType);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return ((Integer) pane.getValue()).intValue();
   }
@@ -1188,7 +1198,7 @@
     JOptionPane pane = new JOptionPane(message, messageType, optionType, icon);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return ((Integer) pane.getValue()).intValue();
   }
@@ -1211,7 +1221,7 @@
     pane.setWantsInput(true);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return (String) pane.getInputValue();
   }
@@ -1237,7 +1247,7 @@
     pane.setWantsInput(true);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return (String) pane.getInputValue();
   }
@@ -1272,7 +1282,7 @@
     pane.setInitialSelectionValue(initialSelectionValue);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return (String) pane.getInputValue();
   }
@@ -1291,7 +1301,7 @@
     JOptionPane pane = new JOptionPane(message);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
 
-    startModal(frame, pane);
+    startModal(frame);
   }
 
   /**
@@ -1311,7 +1321,7 @@
     JOptionPane pane = new JOptionPane(message, messageType);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
   }
 
   /**
@@ -1333,7 +1343,7 @@
     pane.setIcon(icon);
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
   }
 
   /**
@@ -1365,7 +1375,7 @@
 
     JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
 
-    startModal(frame, pane);
+    startModal(frame);
 
     return ((Integer) pane.getValue()).intValue();
   }
@@ -1516,15 +1526,8 @@
    * @param f The JInternalFrame to make modal.
    * @param pane The JOptionPane to add to the JInternalFrame.
    */
-  private static void startModal(JInternalFrame f, JOptionPane pane)
+  private static void startModal(JInternalFrame f)
   {
-    f.getContentPane().add(pane);
-    f.pack();
-    f.show();
-
-    Dimension pref = f.getPreferredSize();
-    f.setBounds(0, 0, pref.width, pref.height);
-
     synchronized (f)
       {
        final JInternalFrame tmp = f;

reply via email to

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