0N/A/*
3909N/A * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage java.awt;
0N/A
0N/Aimport java.awt.peer.MenuComponentPeer;
0N/Aimport java.awt.event.ActionEvent;
0N/Aimport java.io.IOException;
0N/Aimport java.io.ObjectInputStream;
0N/Aimport sun.awt.AppContext;
1338N/Aimport sun.awt.AWTAccessor;
0N/Aimport javax.accessibility.*;
0N/A
3787N/Aimport java.security.AccessControlContext;
3787N/Aimport java.security.AccessController;
3787N/A
0N/A/**
0N/A * The abstract class <code>MenuComponent</code> is the superclass
0N/A * of all menu-related components. In this respect, the class
0N/A * <code>MenuComponent</code> is analogous to the abstract superclass
0N/A * <code>Component</code> for AWT components.
0N/A * <p>
0N/A * Menu components receive and process AWT events, just as components do,
0N/A * through the method <code>processEvent</code>.
0N/A *
0N/A * @author Arthur van Hoff
0N/A * @since JDK1.0
0N/A */
0N/Apublic abstract class MenuComponent implements java.io.Serializable {
0N/A
0N/A static {
0N/A /* ensure that the necessary native libraries are loaded */
0N/A Toolkit.loadLibraries();
0N/A if (!GraphicsEnvironment.isHeadless()) {
0N/A initIDs();
0N/A }
0N/A }
0N/A
0N/A transient MenuComponentPeer peer;
0N/A transient MenuContainer parent;
0N/A
0N/A /**
0N/A * The <code>AppContext</code> of the <code>MenuComponent</code>.
0N/A * This is set in the constructor and never changes.
0N/A */
0N/A transient AppContext appContext;
0N/A
0N/A /**
0N/A * The menu component's font. This value can be
0N/A * <code>null</code> at which point a default will be used.
0N/A * This defaults to <code>null</code>.
0N/A *
0N/A * @serial
0N/A * @see #setFont(Font)
0N/A * @see #getFont()
0N/A */
0N/A Font font;
0N/A
0N/A /**
0N/A * The menu component's name, which defaults to <code>null</code>.
0N/A * @serial
0N/A * @see #getName()
0N/A * @see #setName(String)
0N/A */
0N/A private String name;
0N/A
0N/A /**
0N/A * A variable to indicate whether a name is explicitly set.
0N/A * If <code>true</code> the name will be set explicitly.
0N/A * This defaults to <code>false</code>.
0N/A * @serial
0N/A * @see #setName(String)
0N/A */
0N/A private boolean nameExplicitlySet = false;
0N/A
0N/A /**
0N/A * Defaults to <code>false</code>.
0N/A * @serial
0N/A * @see #dispatchEvent(AWTEvent)
0N/A */
0N/A boolean newEventsOnly = false;
0N/A
0N/A /*
3787N/A * The menu's AccessControlContext.
3787N/A */
3787N/A private transient volatile AccessControlContext acc =
3787N/A AccessController.getContext();
3787N/A
3787N/A /*
3787N/A * Returns the acc this menu component was constructed with.
3787N/A */
3787N/A final AccessControlContext getAccessControlContext() {
3787N/A if (acc == null) {
3787N/A throw new SecurityException(
3787N/A "MenuComponent is missing AccessControlContext");
3787N/A }
3787N/A return acc;
3787N/A }
3787N/A
3787N/A /*
0N/A * Internal constants for serialization.
0N/A */
0N/A final static String actionListenerK = Component.actionListenerK;
0N/A final static String itemListenerK = Component.itemListenerK;
0N/A
0N/A /*
0N/A * JDK 1.1 serialVersionUID
0N/A */
0N/A private static final long serialVersionUID = -4536902356223894379L;
0N/A
1338N/A static {
1338N/A AWTAccessor.setMenuComponentAccessor(
1338N/A new AWTAccessor.MenuComponentAccessor() {
1338N/A public AppContext getAppContext(MenuComponent menuComp) {
1338N/A return menuComp.appContext;
1338N/A }
1338N/A public void setAppContext(MenuComponent menuComp,
1338N/A AppContext appContext) {
1338N/A menuComp.appContext = appContext;
1338N/A }
1338N/A public MenuContainer getParent(MenuComponent menuComp) {
1338N/A return menuComp.parent;
1338N/A }
5255N/A public Font getFont_NoClientCode(MenuComponent menuComp) {
5255N/A return menuComp.getFont_NoClientCode();
5255N/A }
1338N/A });
1338N/A }
1338N/A
0N/A /**
0N/A * Creates a <code>MenuComponent</code>.
0N/A * @exception HeadlessException if
0N/A * <code>GraphicsEnvironment.isHeadless</code>
0N/A * returns <code>true</code>
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A */
0N/A public MenuComponent() throws HeadlessException {
0N/A GraphicsEnvironment.checkHeadless();
0N/A appContext = AppContext.getAppContext();
0N/A }
0N/A
0N/A /**
0N/A * Constructs a name for this <code>MenuComponent</code>.
0N/A * Called by <code>getName</code> when the name is <code>null</code>.
0N/A * @return a name for this <code>MenuComponent</code>
0N/A */
0N/A String constructComponentName() {
0N/A return null; // For strict compliance with prior platform versions, a MenuComponent
0N/A // that doesn't set its name should return null from
0N/A // getName()
0N/A }
0N/A
0N/A /**
0N/A * Gets the name of the menu component.
0N/A * @return the name of the menu component
0N/A * @see java.awt.MenuComponent#setName(java.lang.String)
0N/A * @since JDK1.1
0N/A */
0N/A public String getName() {
0N/A if (name == null && !nameExplicitlySet) {
0N/A synchronized(this) {
0N/A if (name == null && !nameExplicitlySet)
0N/A name = constructComponentName();
0N/A }
0N/A }
0N/A return name;
0N/A }
0N/A
0N/A /**
0N/A * Sets the name of the component to the specified string.
0N/A * @param name the name of the menu component
0N/A * @see java.awt.MenuComponent#getName
0N/A * @since JDK1.1
0N/A */
0N/A public void setName(String name) {
0N/A synchronized(this) {
0N/A this.name = name;
0N/A nameExplicitlySet = true;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns the parent container for this menu component.
0N/A * @return the menu component containing this menu component,
0N/A * or <code>null</code> if this menu component
0N/A * is the outermost component, the menu bar itself
0N/A */
0N/A public MenuContainer getParent() {
0N/A return getParent_NoClientCode();
0N/A }
0N/A // NOTE: This method may be called by privileged threads.
0N/A // This functionality is implemented in a package-private method
0N/A // to insure that it cannot be overridden by client subclasses.
0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
0N/A final MenuContainer getParent_NoClientCode() {
0N/A return parent;
0N/A }
0N/A
0N/A /**
0N/A * @deprecated As of JDK version 1.1,
0N/A * programs should not directly manipulate peers.
0N/A */
0N/A @Deprecated
0N/A public MenuComponentPeer getPeer() {
0N/A return peer;
0N/A }
0N/A
0N/A /**
0N/A * Gets the font used for this menu component.
0N/A * @return the font used in this menu component, if there is one;
0N/A * <code>null</code> otherwise
0N/A * @see java.awt.MenuComponent#setFont
0N/A */
0N/A public Font getFont() {
0N/A Font font = this.font;
0N/A if (font != null) {
0N/A return font;
0N/A }
0N/A MenuContainer parent = this.parent;
0N/A if (parent != null) {
0N/A return parent.getFont();
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A // NOTE: This method may be called by privileged threads.
0N/A // This functionality is implemented in a package-private method
0N/A // to insure that it cannot be overridden by client subclasses.
0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
0N/A final Font getFont_NoClientCode() {
0N/A Font font = this.font;
0N/A if (font != null) {
0N/A return font;
0N/A }
0N/A
0N/A // The MenuContainer interface does not have getFont_NoClientCode()
0N/A // and it cannot, because it must be package-private. Because of
0N/A // this, we must manually cast classes that implement
0N/A // MenuContainer.
0N/A Object parent = this.parent;
0N/A if (parent != null) {
0N/A if (parent instanceof Component) {
0N/A font = ((Component)parent).getFont_NoClientCode();
0N/A } else if (parent instanceof MenuComponent) {
0N/A font = ((MenuComponent)parent).getFont_NoClientCode();
0N/A }
0N/A }
0N/A return font;
0N/A } // getFont_NoClientCode()
0N/A
0N/A
0N/A /**
0N/A * Sets the font to be used for this menu component to the specified
0N/A * font. This font is also used by all subcomponents of this menu
0N/A * component, unless those subcomponents specify a different font.
0N/A * <p>
0N/A * Some platforms may not support setting of all font attributes
0N/A * of a menu component; in such cases, calling <code>setFont</code>
0N/A * will have no effect on the unsupported font attributes of this
0N/A * menu component. Unless subcomponents of this menu component
0N/A * specify a different font, this font will be used by those
0N/A * subcomponents if supported by the underlying platform.
0N/A *
0N/A * @param f the font to be set
0N/A * @see #getFont
0N/A * @see Font#getAttributes
0N/A * @see java.awt.font.TextAttribute
0N/A */
0N/A public void setFont(Font f) {
0N/A font = f;
0N/A //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
0N/A MenuComponentPeer peer = (MenuComponentPeer)this.peer;
0N/A if (peer != null) {
0N/A peer.setFont(f);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Removes the menu component's peer. The peer allows us to modify the
0N/A * appearance of the menu component without changing the functionality of
0N/A * the menu component.
0N/A */
0N/A public void removeNotify() {
0N/A synchronized (getTreeLock()) {
0N/A MenuComponentPeer p = (MenuComponentPeer)this.peer;
0N/A if (p != null) {
0N/A Toolkit.getEventQueue().removeSourceEvents(this, true);
0N/A this.peer = null;
0N/A p.dispose();
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Posts the specified event to the menu.
0N/A * This method is part of the Java&nbsp;1.0 event system
0N/A * and it is maintained only for backwards compatibility.
0N/A * Its use is discouraged, and it may not be supported
0N/A * in the future.
0N/A * @param evt the event which is to take place
0N/A * @deprecated As of JDK version 1.1, replaced by {@link
0N/A * #dispatchEvent(AWTEvent) dispatchEvent}.
0N/A */
0N/A @Deprecated
0N/A public boolean postEvent(Event evt) {
0N/A MenuContainer parent = this.parent;
0N/A if (parent != null) {
0N/A parent.postEvent(evt);
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A /**
0N/A * Delivers an event to this component or one of its sub components.
0N/A * @param e the event
0N/A */
0N/A public final void dispatchEvent(AWTEvent e) {
0N/A dispatchEventImpl(e);
0N/A }
0N/A
0N/A void dispatchEventImpl(AWTEvent e) {
0N/A EventQueue.setCurrentEventAndMostRecentTime(e);
0N/A
0N/A Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);
0N/A
0N/A if (newEventsOnly ||
0N/A (parent != null && parent instanceof MenuComponent &&
0N/A ((MenuComponent)parent).newEventsOnly)) {
0N/A if (eventEnabled(e)) {
0N/A processEvent(e);
0N/A } else if (e instanceof ActionEvent && parent != null) {
0N/A e.setSource(parent);
0N/A ((MenuComponent)parent).dispatchEvent(e);
0N/A }
0N/A
0N/A } else { // backward compatibility
0N/A Event olde = e.convertToOld();
0N/A if (olde != null) {
0N/A postEvent(olde);
0N/A }
0N/A }
0N/A }
0N/A
0N/A // REMIND: remove when filtering is done at lower level
0N/A boolean eventEnabled(AWTEvent e) {
0N/A return false;
0N/A }
0N/A /**
0N/A * Processes events occurring on this menu component.
0N/A * <p>Note that if the event parameter is <code>null</code>
0N/A * the behavior is unspecified and may result in an
0N/A * exception.
0N/A *
0N/A * @param e the event
0N/A * @since JDK1.1
0N/A */
0N/A protected void processEvent(AWTEvent e) {
0N/A }
0N/A
0N/A /**
0N/A * Returns a string representing the state of this
0N/A * <code>MenuComponent</code>. This method is intended to be used
0N/A * only for debugging purposes, and the content and format of the
0N/A * returned string may vary between implementations. The returned
0N/A * string may be empty but may not be <code>null</code>.
0N/A *
0N/A * @return the parameter string of this menu component
0N/A */
0N/A protected String paramString() {
0N/A String thisName = getName();
0N/A return (thisName != null? thisName : "");
0N/A }
0N/A
0N/A /**
0N/A * Returns a representation of this menu component as a string.
0N/A * @return a string representation of this menu component
0N/A */
0N/A public String toString() {
0N/A return getClass().getName() + "[" + paramString() + "]";
0N/A }
0N/A
0N/A /**
0N/A * Gets this component's locking object (the object that owns the thread
0N/A * sychronization monitor) for AWT component-tree and layout
0N/A * operations.
0N/A * @return this component's locking object
0N/A */
0N/A protected final Object getTreeLock() {
0N/A return Component.LOCK;
0N/A }
0N/A
0N/A /**
0N/A * Reads the menu component from an object input stream.
0N/A *
0N/A * @param s the <code>ObjectInputStream</code> to read
0N/A * @exception HeadlessException if
0N/A * <code>GraphicsEnvironment.isHeadless</code> returns
0N/A * <code>true</code>
0N/A * @serial
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A */
0N/A private void readObject(ObjectInputStream s)
0N/A throws ClassNotFoundException, IOException, HeadlessException
0N/A {
0N/A GraphicsEnvironment.checkHeadless();
3787N/A
3787N/A acc = AccessController.getContext();
3787N/A
0N/A s.defaultReadObject();
0N/A
0N/A appContext = AppContext.getAppContext();
0N/A }
0N/A
0N/A /**
0N/A * Initialize JNI field and method IDs.
0N/A */
0N/A private static native void initIDs();
0N/A
0N/A
0N/A /*
0N/A * --- Accessibility Support ---
0N/A *
0N/A * MenuComponent will contain all of the methods in interface Accessible,
0N/A * though it won't actually implement the interface - that will be up
0N/A * to the individual objects which extend MenuComponent.
0N/A */
0N/A
0N/A AccessibleContext accessibleContext = null;
0N/A
0N/A /**
0N/A * Gets the <code>AccessibleContext</code> associated with
0N/A * this <code>MenuComponent</code>.
0N/A *
0N/A * The method implemented by this base class returns <code>null</code>.
0N/A * Classes that extend <code>MenuComponent</code>
0N/A * should implement this method to return the
0N/A * <code>AccessibleContext</code> associated with the subclass.
0N/A *
0N/A * @return the <code>AccessibleContext</code> of this
0N/A * <code>MenuComponent</code>
0N/A * @since 1.3
0N/A */
0N/A public AccessibleContext getAccessibleContext() {
0N/A return accessibleContext;
0N/A }
0N/A
0N/A /**
0N/A * Inner class of <code>MenuComponent</code> used to provide
0N/A * default support for accessibility. This class is not meant
0N/A * to be used directly by application developers, but is instead
0N/A * meant only to be subclassed by menu component developers.
0N/A * <p>
0N/A * The class used to obtain the accessible role for this object.
0N/A * @since 1.3
0N/A */
0N/A protected abstract class AccessibleAWTMenuComponent
0N/A extends AccessibleContext
0N/A implements java.io.Serializable, AccessibleComponent,
0N/A AccessibleSelection
0N/A {
0N/A /*
0N/A * JDK 1.3 serialVersionUID
0N/A */
0N/A private static final long serialVersionUID = -4269533416223798698L;
0N/A
0N/A /**
0N/A * Although the class is abstract, this should be called by
0N/A * all sub-classes.
0N/A */
0N/A protected AccessibleAWTMenuComponent() {
0N/A }
0N/A
0N/A // AccessibleContext methods
0N/A //
0N/A
0N/A /**
0N/A * Gets the <code>AccessibleSelection</code> associated with this
0N/A * object which allows its <code>Accessible</code> children to be selected.
0N/A *
0N/A * @return <code>AccessibleSelection</code> if supported by object;
0N/A * else return <code>null</code>
0N/A * @see AccessibleSelection
0N/A */
0N/A public AccessibleSelection getAccessibleSelection() {
0N/A return this;
0N/A }
0N/A
0N/A /**
0N/A * Gets the accessible name of this object. This should almost never
0N/A * return <code>java.awt.MenuComponent.getName</code>, as that
0N/A * generally isn't a localized name, and doesn't have meaning for the
0N/A * user. If the object is fundamentally a text object (e.g. a menu item), the
0N/A * accessible name should be the text of the object (e.g. "save").
0N/A * If the object has a tooltip, the tooltip text may also be an
0N/A * appropriate String to return.
0N/A *
0N/A * @return the localized name of the object -- can be <code>null</code>
0N/A * if this object does not have a name
0N/A * @see AccessibleContext#setAccessibleName
0N/A */
0N/A public String getAccessibleName() {
0N/A return accessibleName;
0N/A }
0N/A
0N/A /**
0N/A * Gets the accessible description of this object. This should be
0N/A * a concise, localized description of what this object is - what
0N/A * is its meaning to the user. If the object has a tooltip, the
0N/A * tooltip text may be an appropriate string to return, assuming
0N/A * it contains a concise description of the object (instead of just
0N/A * the name of the object - e.g. a "Save" icon on a toolbar that
0N/A * had "save" as the tooltip text shouldn't return the tooltip
0N/A * text as the description, but something like "Saves the current
0N/A * text document" instead).
0N/A *
0N/A * @return the localized description of the object -- can be
0N/A * <code>null</code> if this object does not have a description
0N/A * @see AccessibleContext#setAccessibleDescription
0N/A */
0N/A public String getAccessibleDescription() {
0N/A return accessibleDescription;
0N/A }
0N/A
0N/A /**
0N/A * Gets the role of this object.
0N/A *
0N/A * @return an instance of <code>AccessibleRole</code>
0N/A * describing the role of the object
0N/A * @see AccessibleRole
0N/A */
0N/A public AccessibleRole getAccessibleRole() {
0N/A return AccessibleRole.AWT_COMPONENT; // Non-specific -- overridden in subclasses
0N/A }
0N/A
0N/A /**
0N/A * Gets the state of this object.
0N/A *
0N/A * @return an instance of <code>AccessibleStateSet</code>
0N/A * containing the current state set of the object
0N/A * @see AccessibleState
0N/A */
0N/A public AccessibleStateSet getAccessibleStateSet() {
0N/A return MenuComponent.this.getAccessibleStateSet();
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>Accessible</code> parent of this object.
0N/A * If the parent of this object implements <code>Accessible</code>,
0N/A * this method should simply return <code>getParent</code>.
0N/A *
0N/A * @return the <code>Accessible</code> parent of this object -- can
0N/A * be <code>null</code> if this object does not have an
0N/A * <code>Accessible</code> parent
0N/A */
0N/A public Accessible getAccessibleParent() {
0N/A if (accessibleParent != null) {
0N/A return accessibleParent;
0N/A } else {
0N/A MenuContainer parent = MenuComponent.this.getParent();
0N/A if (parent instanceof Accessible) {
0N/A return (Accessible) parent;
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Gets the index of this object in its accessible parent.
0N/A *
0N/A * @return the index of this object in its parent; -1 if this
0N/A * object does not have an accessible parent
0N/A * @see #getAccessibleParent
0N/A */
0N/A public int getAccessibleIndexInParent() {
0N/A return MenuComponent.this.getAccessibleIndexInParent();
0N/A }
0N/A
0N/A /**
0N/A * Returns the number of accessible children in the object. If all
0N/A * of the children of this object implement <code>Accessible</code>,
0N/A * then this method should return the number of children of this object.
0N/A *
0N/A * @return the number of accessible children in the object
0N/A */
0N/A public int getAccessibleChildrenCount() {
0N/A return 0; // MenuComponents don't have children
0N/A }
0N/A
0N/A /**
0N/A * Returns the nth <code>Accessible</code> child of the object.
0N/A *
0N/A * @param i zero-based index of child
0N/A * @return the nth Accessible child of the object
0N/A */
0N/A public Accessible getAccessibleChild(int i) {
0N/A return null; // MenuComponents don't have children
0N/A }
0N/A
0N/A /**
0N/A * Returns the locale of this object.
0N/A *
0N/A * @return the locale of this object
0N/A */
0N/A public java.util.Locale getLocale() {
0N/A MenuContainer parent = MenuComponent.this.getParent();
0N/A if (parent instanceof Component)
0N/A return ((Component)parent).getLocale();
0N/A else
0N/A return java.util.Locale.getDefault();
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>AccessibleComponent</code> associated with
0N/A * this object if one exists. Otherwise return <code>null</code>.
0N/A *
0N/A * @return the component
0N/A */
0N/A public AccessibleComponent getAccessibleComponent() {
0N/A return this;
0N/A }
0N/A
0N/A
0N/A // AccessibleComponent methods
0N/A //
0N/A /**
0N/A * Gets the background color of this object.
0N/A *
0N/A * @return the background color, if supported, of the object;
0N/A * otherwise, <code>null</code>
0N/A */
0N/A public Color getBackground() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the background color of this object.
0N/A * (For transparency, see <code>isOpaque</code>.)
0N/A *
0N/A * @param c the new <code>Color</code> for the background
0N/A * @see Component#isOpaque
0N/A */
0N/A public void setBackground(Color c) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Gets the foreground color of this object.
0N/A *
0N/A * @return the foreground color, if supported, of the object;
0N/A * otherwise, <code>null</code>
0N/A */
0N/A public Color getForeground() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the foreground color of this object.
0N/A *
0N/A * @param c the new <code>Color</code> for the foreground
0N/A */
0N/A public void setForeground(Color c) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>Cursor</code> of this object.
0N/A *
0N/A * @return the <code>Curso</code>, if supported, of the object;
0N/A * otherwise, <code>null</code>
0N/A */
0N/A public Cursor getCursor() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the <code>Cursor</code> of this object.
0N/A * <p>
0N/A * The method may have no visual effect if the Java platform
0N/A * implementation and/or the native system do not support
0N/A * changing the mouse cursor shape.
0N/A * @param cursor the new <code>Cursor</code> for the object
0N/A */
0N/A public void setCursor(Cursor cursor) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>Font</code> of this object.
0N/A *
0N/A * @return the <code>Font</code>,if supported, for the object;
0N/A * otherwise, <code>null</code>
0N/A */
0N/A public Font getFont() {
0N/A return MenuComponent.this.getFont();
0N/A }
0N/A
0N/A /**
0N/A * Sets the <code>Font</code> of this object.
0N/A *
0N/A * @param f the new <code>Font</code> for the object
0N/A */
0N/A public void setFont(Font f) {
0N/A MenuComponent.this.setFont(f);
0N/A }
0N/A
0N/A /**
0N/A * Gets the <code>FontMetrics</code> of this object.
0N/A *
0N/A * @param f the <code>Font</code>
0N/A * @return the FontMetrics, if supported, the object;
0N/A * otherwise, <code>null</code>
0N/A * @see #getFont
0N/A */
0N/A public FontMetrics getFontMetrics(Font f) {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Determines if the object is enabled.
0N/A *
0N/A * @return true if object is enabled; otherwise, false
0N/A */
0N/A public boolean isEnabled() {
0N/A return true; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the enabled state of the object.
0N/A *
0N/A * @param b if true, enables this object; otherwise, disables it
0N/A */
0N/A public void setEnabled(boolean b) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Determines if the object is visible. Note: this means that the
0N/A * object intends to be visible; however, it may not in fact be
0N/A * showing on the screen because one of the objects that this object
0N/A * is contained by is not visible. To determine if an object is
0N/A * showing on the screen, use <code>isShowing</code>.
0N/A *
0N/A * @return true if object is visible; otherwise, false
0N/A */
0N/A public boolean isVisible() {
0N/A return true; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the visible state of the object.
0N/A *
0N/A * @param b if true, shows this object; otherwise, hides it
0N/A */
0N/A public void setVisible(boolean b) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Determines if the object is showing. This is determined by checking
0N/A * the visibility of the object and ancestors of the object. Note:
0N/A * this will return true even if the object is obscured by another
0N/A * (for example, it happens to be underneath a menu that was pulled
0N/A * down).
0N/A *
0N/A * @return true if object is showing; otherwise, false
0N/A */
0N/A public boolean isShowing() {
0N/A return true; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Checks whether the specified point is within this object's bounds,
0N/A * where the point's x and y coordinates are defined to be relative to
0N/A * the coordinate system of the object.
0N/A *
0N/A * @param p the <code>Point</code> relative to the coordinate
0N/A * system of the object
0N/A * @return true if object contains <code>Point</code>; otherwise false
0N/A */
0N/A public boolean contains(Point p) {
0N/A return false; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Returns the location of the object on the screen.
0N/A *
0N/A * @return location of object on screen -- can be <code>null</code>
0N/A * if this object is not on the screen
0N/A */
0N/A public Point getLocationOnScreen() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Gets the location of the object relative to the parent in the form
0N/A * of a point specifying the object's top-left corner in the screen's
0N/A * coordinate space.
0N/A *
0N/A * @return an instance of <code>Point</code> representing the
0N/A * top-left corner of the object's bounds in the coordinate
0N/A * space of the screen; <code>null</code> if
0N/A * this object or its parent are not on the screen
0N/A */
0N/A public Point getLocation() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the location of the object relative to the parent.
0N/A */
0N/A public void setLocation(Point p) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Gets the bounds of this object in the form of a
0N/A * <code>Rectangle</code> object.
0N/A * The bounds specify this object's width, height, and location
0N/A * relative to its parent.
0N/A *
0N/A * @return a rectangle indicating this component's bounds;
0N/A * <code>null</code> if this object is not on the screen
0N/A */
0N/A public Rectangle getBounds() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Sets the bounds of this object in the form of a
0N/A * <code>Rectangle</code> object.
0N/A * The bounds specify this object's width, height, and location
0N/A * relative to its parent.
0N/A *
0N/A * @param r a rectangle indicating this component's bounds
0N/A */
0N/A public void setBounds(Rectangle r) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Returns the size of this object in the form of a
0N/A * <code>Dimension</code> object. The height field of
0N/A * the <code>Dimension</code> object contains this object's
0N/A * height, and the width field of the <code>Dimension</code>
0N/A * object contains this object's width.
0N/A *
0N/A * @return a <code>Dimension</code> object that indicates the
0N/A * size of this component; <code>null</code>
0N/A * if this object is not on the screen
0N/A */
0N/A public Dimension getSize() {
0N/A return null; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Resizes this object.
0N/A *
0N/A * @param d - the <code>Dimension</code> specifying the
0N/A * new size of the object
0N/A */
0N/A public void setSize(Dimension d) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Returns the <code>Accessible</code> child, if one exists,
0N/A * contained at the local coordinate <code>Point</code>.
0N/A * If there is no <code>Accessible</code> child, <code>null</code>
0N/A * is returned.
0N/A *
0N/A * @param p the point defining the top-left corner of the
0N/A * <code>Accessible</code>, given in the coordinate space
0N/A * of the object's parent
0N/A * @return the <code>Accessible</code>, if it exists,
0N/A * at the specified location; else <code>null</code>
0N/A */
0N/A public Accessible getAccessibleAt(Point p) {
0N/A return null; // MenuComponents don't have children
0N/A }
0N/A
0N/A /**
0N/A * Returns whether this object can accept focus or not.
0N/A *
0N/A * @return true if object can accept focus; otherwise false
0N/A */
0N/A public boolean isFocusTraversable() {
0N/A return true; // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Requests focus for this object.
0N/A */
0N/A public void requestFocus() {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Adds the specified focus listener to receive focus events from this
0N/A * component.
0N/A *
0N/A * @param l the focus listener
0N/A */
0N/A public void addFocusListener(java.awt.event.FocusListener l) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A /**
0N/A * Removes the specified focus listener so it no longer receives focus
0N/A * events from this component.
0N/A *
0N/A * @param l the focus listener
0N/A */
0N/A public void removeFocusListener(java.awt.event.FocusListener l) {
0N/A // Not supported for MenuComponents
0N/A }
0N/A
0N/A // AccessibleSelection methods
0N/A //
0N/A
0N/A /**
0N/A * Returns the number of <code>Accessible</code> children currently selected.
0N/A * If no children are selected, the return value will be 0.
0N/A *
0N/A * @return the number of items currently selected
0N/A */
0N/A public int getAccessibleSelectionCount() {
0N/A return 0; // To be fully implemented in a future release
0N/A }
0N/A
0N/A /**
0N/A * Returns an <code>Accessible</code> representing the specified
0N/A * selected child in the object. If there isn't a selection, or there are
0N/A * fewer children selected than the integer passed in, the return
0N/A * value will be <code>null</code>.
0N/A * <p>Note that the index represents the i-th selected child, which
0N/A * is different from the i-th child.
0N/A *
0N/A * @param i the zero-based index of selected children
0N/A * @return the i-th selected child
0N/A * @see #getAccessibleSelectionCount
0N/A */
0N/A public Accessible getAccessibleSelection(int i) {
0N/A return null; // To be fully implemented in a future release
0N/A }
0N/A
0N/A /**
0N/A * Determines if the current child of this object is selected.
0N/A *
0N/A * @return true if the current child of this object is selected;
0N/A * else false
0N/A * @param i the zero-based index of the child in this
0N/A * <code>Accessible</code> object
0N/A * @see AccessibleContext#getAccessibleChild
0N/A */
0N/A public boolean isAccessibleChildSelected(int i) {
0N/A return false; // To be fully implemented in a future release
0N/A }
0N/A
0N/A /**
0N/A * Adds the specified <code>Accessible</code> child of the object
0N/A * to the object's selection. If the object supports multiple selections,
0N/A * the specified child is added to any existing selection, otherwise
0N/A * it replaces any existing selection in the object. If the
0N/A * specified child is already selected, this method has no effect.
0N/A *
0N/A * @param i the zero-based index of the child
0N/A * @see AccessibleContext#getAccessibleChild
0N/A */
0N/A public void addAccessibleSelection(int i) {
0N/A // To be fully implemented in a future release
0N/A }
0N/A
0N/A /**
0N/A * Removes the specified child of the object from the object's
0N/A * selection. If the specified item isn't currently selected, this
0N/A * method has no effect.
0N/A *
0N/A * @param i the zero-based index of the child
0N/A * @see AccessibleContext#getAccessibleChild
0N/A */
0N/A public void removeAccessibleSelection(int i) {
0N/A // To be fully implemented in a future release
0N/A }
0N/A
0N/A /**
0N/A * Clears the selection in the object, so that no children in the
0N/A * object are selected.
0N/A */
0N/A public void clearAccessibleSelection() {
0N/A // To be fully implemented in a future release
0N/A }
0N/A
0N/A /**
0N/A * Causes every child of the object to be selected
0N/A * if the object supports multiple selections.
0N/A */
0N/A public void selectAllAccessibleSelection() {
0N/A // To be fully implemented in a future release
0N/A }
0N/A
0N/A } // inner class AccessibleAWTComponent
0N/A
0N/A /**
0N/A * Gets the index of this object in its accessible parent.
0N/A *
0N/A * @return -1 if this object does not have an accessible parent;
0N/A * otherwise, the index of the child in its accessible parent.
0N/A */
0N/A int getAccessibleIndexInParent() {
0N/A MenuContainer localParent = parent;
0N/A if (!(localParent instanceof MenuComponent)) {
0N/A // MenuComponents only have accessible index when inside MenuComponents
0N/A return -1;
0N/A }
0N/A MenuComponent localParentMenu = (MenuComponent)localParent;
0N/A return localParentMenu.getAccessibleChildIndex(this);
0N/A }
0N/A
0N/A /**
0N/A * Gets the index of the child within this MenuComponent.
0N/A *
0N/A * @param child MenuComponent whose index we are interested in.
0N/A * @return -1 if this object doesn't contain the child,
0N/A * otherwise, index of the child.
0N/A */
0N/A int getAccessibleChildIndex(MenuComponent child) {
0N/A return -1; // Overridden in subclasses.
0N/A }
0N/A
0N/A /**
0N/A * Gets the state of this object.
0N/A *
0N/A * @return an instance of <code>AccessibleStateSet</code>
0N/A * containing the current state set of the object
0N/A * @see AccessibleState
0N/A */
0N/A AccessibleStateSet getAccessibleStateSet() {
0N/A AccessibleStateSet states = new AccessibleStateSet();
0N/A return states;
0N/A }
0N/A
0N/A}