Hi, this fixes an issue I had with JWindow. The constructor JWindow(Frame) is allowed to take a null parameter and in that case should install a shared owner frame (as returned by SwingUtilites.getOwnerFrame). However, the implementation of this is a little tricky, since the super class does not allow null parameters. So I changed the SwingUtilities.getOwnerFrame() method (this is not public) to take a parameter 'owner' which is returned when not null. Later it came to mind that I also could have solved this problem with a super(owner == null? SwingUtilities.getOwnerFrame():owner) construct, however I really don't like the ?: expression, I feel Sun really should have left this out of Java :-)
I had to adjust a couple of other classes for the changed SwingUtilities.getOwnerFrame() method, one of which is JFileChooser. Unfortunately I had a fix for this class lying around on my HD, which is now also going in. This is to call pack() in the showXXXDialog() methods. I feel that this will break the JFileChooser a little, but I already know how to fix it (I only must find time to do it - basically we need a special subclass of JList that displays the files) 2006-01-19 Roman Kennke <[EMAIL PROTECTED]> * javax/swing/JDialog.java (JDialog()): Call SwingUtilities.getOwnerFrame() with null. (JDialog(Frame,String,boolean,GraphicsConfiguration)): Call SwingUtilities.getOwnerFrame() with the owner argument. * javax/swing/JFileChooser.java (showOpenDialog(Component)): Call pack() on the dialog instead of setting a fixed height. (showSaveDialog()): Likewise. (showDialog()): Likewise. (createDialog): Call SwingUtilities.getOwnerFrame() with null. * javax/swing/JOptionPane.java: Call SwingUtilities.getOwnerFrame() with null. * javax/swing/JWindow.java (JWindow()): Call SwingUtilities.getOwnerFrame() with null. (JWindow(Frame)): Call SwingUtilities.getOwnerFrame() with owner argument. * javax/swing/SwingUtilities.java (getOwnerFrame): Changed to take a owner parameter that is returned as owner frame when not null. /Roman
Index: javax/swing/JDialog.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JDialog.java,v retrieving revision 1.19 diff -u -r1.19 JDialog.java --- javax/swing/JDialog.java 7 Nov 2005 22:05:10 -0000 1.19 +++ javax/swing/JDialog.java 19 Jan 2006 21:17:59 -0000 @@ -107,7 +107,7 @@ */ public JDialog() { - this(SwingUtilities.getOwnerFrame(), "", false, null); + this(SwingUtilities.getOwnerFrame(null), "", false, null); } /** @@ -234,8 +234,7 @@ public JDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) { - super((owner == null) ? SwingUtilities.getOwnerFrame() : owner, - title, modal, gc); + super(SwingUtilities.getOwnerFrame(owner), title, modal, gc); dialogInit(); } Index: javax/swing/JFileChooser.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JFileChooser.java,v retrieving revision 1.25 diff -u -r1.25 JFileChooser.java --- javax/swing/JFileChooser.java 4 Jan 2006 23:22:01 -0000 1.25 +++ javax/swing/JFileChooser.java 19 Jan 2006 21:17:59 -0000 @@ -40,7 +40,6 @@ import java.awt.Component; import java.awt.Frame; import java.awt.HeadlessException; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; @@ -658,8 +657,7 @@ retval = ERROR_OPTION; - Insets i = d.getInsets(); - d.setSize(500 + i.top + i.bottom, d.getPreferredSize().height); + d.pack(); d.show(); return retval; } @@ -683,8 +681,7 @@ retval = ERROR_OPTION; - Insets i = d.getInsets(); - d.setSize(500 + i.top + i.bottom, d.getPreferredSize().height); + d.pack(); d.show(); return retval; } @@ -710,8 +707,7 @@ retval = ERROR_OPTION; - Insets i = d.getInsets(); - d.setSize(500 + i.top + i.bottom, d.getPreferredSize().height); + d.pack(); d.show(); return retval; } @@ -729,7 +725,7 @@ { Frame toUse = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); if (toUse == null) - toUse = SwingUtilities.getOwnerFrame(); + toUse = SwingUtilities.getOwnerFrame(null); JDialog dialog = new JDialog(toUse); setSelectedFile(null); Index: javax/swing/JOptionPane.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JOptionPane.java,v retrieving revision 1.23 diff -u -r1.23 JOptionPane.java --- javax/swing/JOptionPane.java 8 Nov 2005 20:59:05 -0000 1.23 +++ javax/swing/JOptionPane.java 19 Jan 2006 21:17:59 -0000 @@ -236,7 +236,7 @@ protected boolean wantsInput; /** The common frame used when no parent is provided. */ - private static Frame privFrame = SwingUtilities.getOwnerFrame(); + private static Frame privFrame = SwingUtilities.getOwnerFrame(null); /** * Creates a new JOptionPane object using a message of "JOptionPane Index: javax/swing/JWindow.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JWindow.java,v retrieving revision 1.22 diff -u -r1.22 JWindow.java --- javax/swing/JWindow.java 7 Nov 2005 22:05:10 -0000 1.22 +++ javax/swing/JWindow.java 19 Jan 2006 21:18:00 -0000 @@ -88,19 +88,19 @@ public JWindow() { - super(SwingUtilities.getOwnerFrame()); + super(SwingUtilities.getOwnerFrame(null)); windowInit(); } public JWindow(GraphicsConfiguration gc) { - super(SwingUtilities.getOwnerFrame(), gc); + super(SwingUtilities.getOwnerFrame(null), gc); windowInit(); } public JWindow(Frame owner) { - super(owner); + super(SwingUtilities.getOwnerFrame(owner)); windowInit(); } Index: javax/swing/SwingUtilities.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v retrieving revision 1.40 diff -u -r1.40 SwingUtilities.java --- javax/swing/SwingUtilities.java 17 Dec 2005 00:23:54 -0000 1.40 +++ javax/swing/SwingUtilities.java 19 Jan 2006 21:18:00 -0000 @@ -1021,11 +1021,16 @@ * * @return The common Frame */ - static Frame getOwnerFrame() + static Frame getOwnerFrame(Frame owner) { - if (ownerFrame == null) - ownerFrame = new OwnerFrame(); - return ownerFrame; + Frame result = owner; + if (result == null) + { + if (ownerFrame == null) + ownerFrame = new OwnerFrame(); + result = ownerFrame; + } + return result; } /**
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches