src/java.desktop/share/classes/java/awt/MenuComponent.java

Print this page

        

@@ -28,10 +28,12 @@
 import java.awt.event.ActionEvent;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import sun.awt.AppContext;
 import sun.awt.AWTAccessor;
+import sun.awt.ComponentFactory;
+
 import javax.accessibility.*;
 
 import java.security.AccessControlContext;
 import java.security.AccessController;
 

@@ -182,10 +184,18 @@
         return null; // For strict compliance with prior platform versions, a MenuComponent
                      // that doesn't set its name should return null from
                      // getName()
     }
 
+    final ComponentFactory getComponentFactory() {
+        final Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if (toolkit instanceof ComponentFactory) {
+            return (ComponentFactory) toolkit;
+        }
+        throw new AWTError("Unsupported toolkit: " + toolkit);
+    }
+
     /**
      * Gets the name of the menu component.
      * @return        the name of the menu component
      * @see           java.awt.MenuComponent#setName(java.lang.String)
      * @since         1.1