Window decorations: fixed exception in SwingUtilities.convertPoint() when doing new JDialog( (Window) null )

regression since commits 54e6cefa67 and
fb37be5734
This commit is contained in:
Karl Tauber
2021-11-15 00:11:28 +01:00
parent fcc39b2db5
commit ce049ea3ee

View File

@@ -224,6 +224,11 @@ public class FlatTitlePane
restoreButton = createButton( "TitlePane.restoreIcon", "Restore", e -> restore() );
closeButton = createButton( "TitlePane.closeIcon", "Close", e -> close() );
// initially hide buttons that are only supported in frames
iconifyButton.setVisible( false );
maximizeButton.setVisible( false );
restoreButton.setVisible( false );
buttonPanel = new JPanel() {
@Override
public Dimension getPreferredSize() {
@@ -243,11 +248,9 @@ public class FlatTitlePane
if( rootPane.getWindowDecorationStyle() == JRootPane.FRAME ) {
// JRootPane.FRAME works only for frames (and not for dialogs)
// but at this time the owner window type is unknown (not yet added)
// so we add the iconify/maximize/restore buttons and they are hidden
// so we add the iconify/maximize/restore buttons and they are shown
// later in frameStateChanged(), which is invoked from addNotify()
restoreButton.setVisible( false );
buttonPanel.add( iconifyButton );
buttonPanel.add( maximizeButton );
buttonPanel.add( restoreButton );
@@ -813,7 +816,7 @@ debug*/
}
private Rectangle boundsInWindow( JComponent c ) {
return c.isVisible()
return c.isShowing()
? SwingUtilities.convertRectangle( c.getParent(), c.getBounds(), window )
: null;
}