diff options
Diffstat (limited to 'libjava/classpath/javax/swing/JRootPane.java')
-rw-r--r-- | libjava/classpath/javax/swing/JRootPane.java | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/libjava/classpath/javax/swing/JRootPane.java b/libjava/classpath/javax/swing/JRootPane.java index dea4ee4b195..dec43956ca3 100644 --- a/libjava/classpath/javax/swing/JRootPane.java +++ b/libjava/classpath/javax/swing/JRootPane.java @@ -120,11 +120,6 @@ public class JRootPane extends JComponent implements Accessible private Rectangle menuBarBounds; /** - * The cached preferred size. - */ - private Dimension prefSize; - - /** * Creates a new <code>RootLayout</code> object. */ protected RootLayout() @@ -191,7 +186,6 @@ public class JRootPane extends JComponent implements Accessible layeredPaneBounds = null; contentPaneBounds = null; menuBarBounds = null; - prefSize = null; } } @@ -251,7 +245,7 @@ public class JRootPane extends JComponent implements Accessible layeredPane.setBounds(layeredPaneBounds); if (menuBar != null) menuBar.setBounds(menuBarBounds); - contentPane.setBounds(contentPaneBounds); + getContentPane().setBounds(contentPaneBounds); } /** @@ -287,29 +281,20 @@ public class JRootPane extends JComponent implements Accessible */ public Dimension preferredLayoutSize(Container c) { - // We must synchronize here, otherwise we cannot guarantee that the - // prefSize is still non-null when returning. - synchronized (this) + Dimension prefSize = new Dimension(); + Insets i = getInsets(); + prefSize = new Dimension(i.left + i.right, i.top + i.bottom); + Dimension contentPrefSize = getContentPane().getPreferredSize(); + prefSize.width += contentPrefSize.width; + prefSize.height += contentPrefSize.height; + if (menuBar != null) { - if (prefSize == null) - { - Insets i = getInsets(); - prefSize = new Dimension(i.left + i.right, i.top + i.bottom); - Dimension contentPrefSize = contentPane.getPreferredSize(); - prefSize.width += contentPrefSize.width; - prefSize.height += contentPrefSize.height; - if (menuBar != null) - { - Dimension menuBarSize = menuBar.getPreferredSize(); - if (menuBarSize.width > contentPrefSize.width) - prefSize.width += menuBarSize.width - contentPrefSize.width; - prefSize.height += menuBarSize.height; - } - } - // Return a copy here so the cached value won't get trashed by some - // other component. - return new Dimension(prefSize); - } + Dimension menuBarSize = menuBar.getPreferredSize(); + if (menuBarSize.width > contentPrefSize.width) + prefSize.width += menuBarSize.width - contentPrefSize.width; + prefSize.height += menuBarSize.height; + } + return prefSize; } /** @@ -541,6 +526,7 @@ public class JRootPane extends JComponent implements Accessible getGlassPane(); getLayeredPane(); getContentPane(); + setOpaque(true); updateUI(); } @@ -674,4 +660,18 @@ public class JRootPane extends JComponent implements Accessible windowDecorationStyle = style; firePropertyChange("windowDecorationStyle", oldStyle, style); } + + /** + * This returns <code>true</code> if the <code>glassPane</code> is not + * visible because then the root pane can guarantee to tile its children + * (the only other direct child is a JLayeredPane which must figure its + * <code>optimizeDrawingEnabled</code> state on its own). + * + * @return <code>true</code> if the <code>glassPane</code> is not + * visible + */ + public boolean isOptimizedDrawingEnable() + { + return ! glassPane.isVisible(); + } } |