--- a/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java Wed May 13 14:25:22 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JApplet.java Thu May 14 02:05:02 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,18 @@
*/
package javax.swing;
-import java.awt.*;
-import java.awt.event.*;
import java.applet.Applet;
-import java.beans.PropertyChangeListener;
-import java.util.Locale;
-import java.util.Vector;
-import java.io.Serializable;
-import javax.accessibility.*;
+import java.awt.AWTEvent;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.HeadlessException;
+import java.awt.LayoutManager;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
/**
* An extended version of <code>java.applet.Applet</code> that adds support for
@@ -243,9 +247,8 @@
* hidden: true
* description: The menubar for accessing pulldown menus from this applet.
*/
- @SuppressWarnings("deprecation")
- public void setJMenuBar(JMenuBar menuBar) {
- getRootPane().setMenuBar(menuBar);
+ public void setJMenuBar(final JMenuBar menuBar) {
+ getRootPane().setJMenuBar(menuBar);
}
/**
@@ -254,9 +257,8 @@
* @return the menubar set on this applet
* @see #setJMenuBar
*/
- @SuppressWarnings("deprecation")
public JMenuBar getJMenuBar() {
- return getRootPane().getMenuBar();
+ return getRootPane().getJMenuBar();
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/JDialog.java Wed May 13 14:25:22 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JDialog.java Thu May 14 02:05:02 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -849,9 +849,8 @@
* hidden: true
* description: The menubar for accessing pulldown menus from this dialog.
*/
- @SuppressWarnings("deprecation")
- public void setJMenuBar(JMenuBar menu) {
- getRootPane().setMenuBar(menu);
+ public void setJMenuBar(final JMenuBar menu) {
+ getRootPane().setJMenuBar(menu);
}
/**
@@ -860,12 +859,10 @@
* @return the menubar set on this dialog
* @see #setJMenuBar
*/
- @SuppressWarnings("deprecation")
public JMenuBar getJMenuBar() {
- return getRootPane().getMenuBar();
+ return getRootPane().getJMenuBar();
}
-
/**
* Returns whether calls to {@code add} and
* {@code setLayout} are forwarded to the {@code contentPane}.
--- a/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java Wed May 13 14:25:22 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java Thu May 14 02:05:02 2015 +0300
@@ -486,9 +486,8 @@
* hidden: true
* description: The menubar for accessing pulldown menus from this frame.
*/
- @SuppressWarnings("deprecation")
- public void setJMenuBar(JMenuBar menubar) {
- getRootPane().setMenuBar(menubar);
+ public void setJMenuBar(final JMenuBar menubar) {
+ getRootPane().setJMenuBar(menubar);
}
/**
@@ -497,9 +496,8 @@
*
* @see #setJMenuBar
*/
- @SuppressWarnings("deprecation")
public JMenuBar getJMenuBar() {
- return getRootPane().getMenuBar();
+ return getRootPane().getJMenuBar();
}
/**
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java Wed May 13 14:25:22 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalRootPaneUI.java Thu May 14 02:05:02 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,11 @@
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import javax.swing.*;
-import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
-import java.io.*;
-import java.security.*;
/**
* Provides the metal look and feel implementation of <code>RootPaneUI</code>.
@@ -441,7 +437,6 @@
* @param the Container for which this layout manager is being used
* @return a Dimension object containing the layout's preferred size
*/
- @SuppressWarnings("deprecation")
public Dimension preferredLayoutSize(Container parent) {
Dimension cpd, mbd, tpd;
int cpWidth = 0;
@@ -463,8 +458,8 @@
cpHeight = cpd.height;
}
- if(root.getMenuBar() != null) {
- mbd = root.getMenuBar().getPreferredSize();
+ if(root.getJMenuBar() != null) {
+ mbd = root.getJMenuBar().getPreferredSize();
if (mbd != null) {
mbWidth = mbd.width;
mbHeight = mbd.height;
@@ -494,7 +489,6 @@
* @param the Container for which this layout manager is being used
* @return a Dimension object containing the layout's minimum size
*/
- @SuppressWarnings("deprecation")
public Dimension minimumLayoutSize(Container parent) {
Dimension cpd, mbd, tpd;
int cpWidth = 0;
@@ -516,8 +510,8 @@
cpHeight = cpd.height;
}
- if(root.getMenuBar() != null) {
- mbd = root.getMenuBar().getMinimumSize();
+ if(root.getJMenuBar() != null) {
+ mbd = root.getJMenuBar().getMinimumSize();
if (mbd != null) {
mbWidth = mbd.width;
mbHeight = mbd.height;
@@ -546,7 +540,6 @@
* @param the Container for which this layout manager is being used
* @return a Dimension object containing the layout's maximum size
*/
- @SuppressWarnings("deprecation")
public Dimension maximumLayoutSize(Container target) {
Dimension cpd, mbd, tpd;
int cpWidth = Integer.MAX_VALUE;
@@ -566,8 +559,8 @@
}
}
- if(root.getMenuBar() != null) {
- mbd = root.getMenuBar().getMaximumSize();
+ if(root.getJMenuBar() != null) {
+ mbd = root.getJMenuBar().getMaximumSize();
if (mbd != null) {
mbWidth = mbd.width;
mbHeight = mbd.height;
@@ -610,7 +603,6 @@
*
* @param the Container for which this layout manager is being used
*/
- @SuppressWarnings("deprecation")
public void layoutContainer(Container parent) {
JRootPane root = (JRootPane) parent;
Rectangle b = root.getBounds();
@@ -640,9 +632,9 @@
}
}
}
- if(root.getMenuBar() != null) {
- Dimension mbd = root.getMenuBar().getPreferredSize();
- root.getMenuBar().setBounds(0, nextY, w, mbd.height);
+ if(root.getJMenuBar() != null) {
+ Dimension mbd = root.getJMenuBar().getPreferredSize();
+ root.getJMenuBar().setBounds(0, nextY, w, mbd.height);
nextY += mbd.height;
}
if(root.getContentPane() != null) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JRootPane/SilenceOfDeprecatedMenuBar/SilenceOfDeprecatedMenuBar.java Thu May 14 02:05:02 2015 +0300
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JMenuBar;
+import javax.swing.JRootPane;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+import static javax.swing.UIManager.getInstalledLookAndFeels;
+
+/**
+ * @test
+ * @bug 6368321
+ * @author Sergey Bylokhov
+ */
+public final class SilenceOfDeprecatedMenuBar implements Runnable {
+
+ public static void main(final String[] args) throws Exception {
+ for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
+ SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
+ SwingUtilities.invokeAndWait(new SilenceOfDeprecatedMenuBar());
+ }
+ }
+
+ @Override
+ public void run() {
+ final JFrame frame = new DeprecatedFrame();
+ try {
+ final JMenuBar bar = new JMenuBar();
+ frame.setJMenuBar(bar);
+ frame.setBounds(100, 100, 100, 100);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ if (bar != frame.getJMenuBar()) {
+ throw new RuntimeException("Wrong JMenuBar");
+ }
+ } finally {
+ frame.dispose();
+ }
+ }
+
+ private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) {
+ try {
+ UIManager.setLookAndFeel(laf.getClassName());
+ System.out.println("LookAndFeel: " + laf.getClassName());
+ } catch (ClassNotFoundException | InstantiationException |
+ UnsupportedLookAndFeelException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static class DeprecatedFrame extends JFrame {
+
+ @Override
+ protected JRootPane createRootPane() {
+ return new JRootPane() {
+ @Override
+ public JMenuBar getMenuBar() {
+ throw new RuntimeException("Should not be here");
+ }
+ @Override
+ public void setMenuBar(final JMenuBar menu) {
+ throw new RuntimeException("Should not be here");
+ }
+ };
+ }
+ }
+}