diff --git a/test/javax/swing/JCheckBox/4449413/bug4449413.html b/test/javax/swing/JCheckBox/4449413/bug4449413.html
new file mode 100644
index 0000000..cec2ce0
--- /dev/null
+++ b/test/javax/swing/JCheckBox/4449413/bug4449413.html
@@ -0,0 +1,17 @@
+<html>
+<body>
+When the applet starts, you'll see eight controls with black backgrounds.
+Four enabled (on the left side) and four disabled (on the right side)
+checkboxes and radiobuttons.
+
+1. If at least one of the controls' check marks is not visible:
+   the test fails.
+
+2. Uncheck the "Use Ocean Theme" check box. 
+   If now at least one of the controls' check marks is not visible:
+   the test fails.
+
+<applet  code="bug4449413.class" width=250 height=190></applet>
+
+</body>
+</html>
diff --git a/test/javax/swing/JCheckBox/4449413/bug4449413.java b/test/javax/swing/JCheckBox/4449413/bug4449413.java
new file mode 100644
index 0000000..4fd8efd
--- /dev/null
+++ b/test/javax/swing/JCheckBox/4449413/bug4449413.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+
+/* @test
+ * @bug 4449413
+ * @summary Tests that checkbox and radiobuttons' check marks are visible when background is black
+ * @author Ilya Boyandin
+ * @run applet/manual=yesno bug4449413.html
+ */
+
+import javax.swing.*;
+import javax.swing.plaf.metal.*;
+import java.awt.event.*;
+import java.awt.*;
+import sun.awt.OSInfo;
+
+public class bug4449413 extends JApplet {
+
+    @Override
+    public void init() {
+
+        try {
+
+            if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+                UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+            }
+
+            final MetalTheme oceanTheme = (MetalTheme) sun.awt.AppContext.getAppContext().get("currentMetalTheme");
+
+
+            SwingUtilities.invokeAndWait(new Runnable() {
+
+                @Override
+                public void run() {
+                    getContentPane().setLayout(new FlowLayout());
+                    final JPanel panel = new JPanel();
+
+                    JCheckBox box = new JCheckBox("Use Ocean theme", true);
+                    getContentPane().add(box);
+                    box.addItemListener(new ItemListener() {
+
+                        @Override
+                        public void itemStateChanged(ItemEvent e) {
+                            if (e.getStateChange() == ItemEvent.SELECTED) {
+                                MetalLookAndFeel.setCurrentTheme(oceanTheme);
+                            } else {
+                                MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
+                            }
+                            SwingUtilities.updateComponentTreeUI(panel);
+                        }
+                    });
+
+                    getContentPane().add(panel);
+                    panel.setLayout(new GridLayout(4, 6, 10, 15));
+                    for (int k = 0; k <= 3; k++) {
+                        for (int j = 1; j >= 0; j--) {
+                            AbstractButton b = createButton(j, k);
+                            panel.add(b);
+                        }
+                    }
+                }
+            });
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    static AbstractButton createButton(int enabled, int type) {
+        AbstractButton b = null;
+        switch (type) {
+            case 0:
+                b = new JRadioButton("RadioButton");
+                break;
+            case 1:
+                b = new JCheckBox("CheckBox");
+                break;
+            case 2:
+                b = new JRadioButtonMenuItem("RBMenuItem");
+                break;
+            case 3:
+                b = new JCheckBoxMenuItem("CBMenuItem");
+                break;
+        }
+        b.setBackground(Color.black);
+        b.setForeground(Color.white);
+        b.setEnabled(enabled == 1);
+        b.setSelected(true);
+        return b;
+    }
+}
