Source Code Cross Referenced for MenuComponent.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001        /*
0002         * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
0003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0004         *
0005         * This code is free software; you can redistribute it and/or modify it
0006         * under the terms of the GNU General Public License version 2 only, as
0007         * published by the Free Software Foundation.  Sun designates this
0008         * particular file as subject to the "Classpath" exception as provided
0009         * by Sun in the LICENSE file that accompanied this code.
0010         *
0011         * This code is distributed in the hope that it will be useful, but WITHOUT
0012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0014         * version 2 for more details (a copy is included in the LICENSE file that
0015         * accompanied this code).
0016         *
0017         * You should have received a copy of the GNU General Public License version
0018         * 2 along with this work; if not, write to the Free Software Foundation,
0019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0020         *
0021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0022         * CA 95054 USA or visit www.sun.com if you need additional information or
0023         * have any questions.
0024         */
0025        package java.awt;
0026
0027        import java.awt.peer.MenuComponentPeer;
0028        import java.awt.event.ActionEvent;
0029        import java.io.IOException;
0030        import java.io.ObjectInputStream;
0031        import sun.awt.AppContext;
0032        import sun.awt.SunToolkit;
0033        import javax.accessibility.*;
0034
0035        /**
0036         * The abstract class <code>MenuComponent</code> is the superclass 
0037         * of all menu-related components. In this respect, the class
0038         * <code>MenuComponent</code> is analogous to the abstract superclass
0039         * <code>Component</code> for AWT components.
0040         * <p>
0041         * Menu components receive and process AWT events, just as components do,
0042         * through the method <code>processEvent</code>.
0043         *
0044         * @version 	1.88, 05/05/07
0045         * @author 	Arthur van Hoff
0046         * @since       JDK1.0
0047         */
0048        public abstract class MenuComponent implements  java.io.Serializable {
0049
0050            static {
0051                /* ensure that the necessary native libraries are loaded */
0052                Toolkit.loadLibraries();
0053                if (!GraphicsEnvironment.isHeadless()) {
0054                    initIDs();
0055                }
0056            }
0057
0058            transient MenuComponentPeer peer;
0059            transient MenuContainer parent;
0060
0061            /**
0062             * The <code>AppContext</code> of the <code>MenuComponent</code>.
0063             * This is set in the constructor and never changes.
0064             */
0065            transient AppContext appContext;
0066
0067            /**
0068             * The menu component's font. This value can be 
0069             * <code>null</code> at which point a default will be used.
0070             * This defaults to <code>null</code>.
0071             *
0072             * @serial
0073             * @see #setFont(Font)
0074             * @see #getFont()
0075             */
0076            Font font;
0077
0078            /**
0079             * The menu component's name, which defaults to <code>null</code>.
0080             * @serial
0081             * @see #getName()
0082             * @see #setName(String)
0083             */
0084            private String name;
0085
0086            /**
0087             * A variable to indicate whether a name is explicitly set.
0088             * If <code>true</code> the name will be set explicitly. 
0089             * This defaults to <code>false</code>.
0090             * @serial
0091             * @see #setName(String)
0092             */
0093            private boolean nameExplicitlySet = false;
0094
0095            /**
0096             * Defaults to <code>false</code>.
0097             * @serial
0098             * @see #dispatchEvent(AWTEvent)
0099             */
0100            boolean newEventsOnly = false;
0101
0102            /*
0103             * Internal constants for serialization.
0104             */
0105            final static String actionListenerK = Component.actionListenerK;
0106            final static String itemListenerK = Component.itemListenerK;
0107
0108            /*
0109             * JDK 1.1 serialVersionUID 
0110             */
0111            private static final long serialVersionUID = -4536902356223894379L;
0112
0113            /**
0114             * Creates a <code>MenuComponent</code>.
0115             * @exception HeadlessException if
0116             *    <code>GraphicsEnvironment.isHeadless</code>
0117             *    returns <code>true</code>
0118             * @see java.awt.GraphicsEnvironment#isHeadless
0119             */
0120            public MenuComponent() throws HeadlessException {
0121                GraphicsEnvironment.checkHeadless();
0122                appContext = AppContext.getAppContext();
0123            }
0124
0125            /**
0126             * Constructs a name for this <code>MenuComponent</code>.
0127             * Called by <code>getName</code> when the name is <code>null</code>.
0128             * @return a name for this <code>MenuComponent</code>
0129             */
0130            String constructComponentName() {
0131                return null; // For strict compliance with prior platform versions, a MenuComponent
0132                // that doesn't set its name should return null from
0133                // getName()
0134            }
0135
0136            /**
0137             * Gets the name of the menu component.
0138             * @return        the name of the menu component
0139             * @see           java.awt.MenuComponent#setName(java.lang.String)
0140             * @since         JDK1.1
0141             */
0142            public String getName() {
0143                if (name == null && !nameExplicitlySet) {
0144                    synchronized (this ) {
0145                        if (name == null && !nameExplicitlySet)
0146                            name = constructComponentName();
0147                    }
0148                }
0149                return name;
0150            }
0151
0152            /**
0153             * Sets the name of the component to the specified string.
0154             * @param         name    the name of the menu component
0155             * @see           java.awt.MenuComponent#getName
0156             * @since         JDK1.1
0157             */
0158            public void setName(String name) {
0159                synchronized (this ) {
0160                    this .name = name;
0161                    nameExplicitlySet = true;
0162                }
0163            }
0164
0165            /**
0166             * Returns the parent container for this menu component.
0167             * @return    the menu component containing this menu component, 
0168             *                 or <code>null</code> if this menu component 
0169             *                 is the outermost component, the menu bar itself
0170             */
0171            public MenuContainer getParent() {
0172                return getParent_NoClientCode();
0173            }
0174
0175            // NOTE: This method may be called by privileged threads.
0176            //       This functionality is implemented in a package-private method 
0177            //       to insure that it cannot be overridden by client subclasses. 
0178            //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
0179            final MenuContainer getParent_NoClientCode() {
0180                return parent;
0181            }
0182
0183            /**
0184             * @deprecated As of JDK version 1.1,
0185             * programs should not directly manipulate peers.
0186             */
0187            @Deprecated
0188            public MenuComponentPeer getPeer() {
0189                return peer;
0190            }
0191
0192            /**
0193             * Gets the font used for this menu component.
0194             * @return   the font used in this menu component, if there is one; 
0195             *                  <code>null</code> otherwise
0196             * @see     java.awt.MenuComponent#setFont
0197             */
0198            public Font getFont() {
0199                Font font = this .font;
0200                if (font != null) {
0201                    return font;
0202                }
0203                MenuContainer parent = this .parent;
0204                if (parent != null) {
0205                    return parent.getFont();
0206                }
0207                return null;
0208            }
0209
0210            // NOTE: This method may be called by privileged threads.
0211            //       This functionality is implemented in a package-private method 
0212            //       to insure that it cannot be overridden by client subclasses. 
0213            //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
0214            final Font getFont_NoClientCode() {
0215                Font font = this .font;
0216                if (font != null) {
0217                    return font;
0218                }
0219
0220                // The MenuContainer interface does not have getFont_NoClientCode()
0221                // and it cannot, because it must be package-private. Because of
0222                // this, we must manually cast classes that implement 
0223                // MenuContainer.
0224                Object parent = this .parent;
0225                if (parent != null) {
0226                    if (parent instanceof  Component) {
0227                        font = ((Component) parent).getFont_NoClientCode();
0228                    } else if (parent instanceof  MenuComponent) {
0229                        font = ((MenuComponent) parent).getFont_NoClientCode();
0230                    }
0231                }
0232                return font;
0233            } // getFont_NoClientCode()
0234
0235            /**
0236             * Sets the font to be used for this menu component to the specified 
0237             * font. This font is also used by all subcomponents of this menu 
0238             * component, unless those subcomponents specify a different font. 
0239             * <p>
0240             * Some platforms may not support setting of all font attributes 
0241             * of a menu component; in such cases, calling <code>setFont</code>
0242             * will have no effect on the unsupported font attributes of this 
0243             * menu component.  Unless subcomponents of this menu component 
0244             * specify a different font, this font will be used by those 
0245             * subcomponents if supported by the underlying platform.  
0246             *
0247             * @param     f   the font to be set
0248             * @see       #getFont
0249             * @see       Font#getAttributes
0250             * @see       java.awt.font.TextAttribute
0251             */
0252            public void setFont(Font f) {
0253                font = f;
0254                //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
0255                MenuComponentPeer peer = (MenuComponentPeer) this .peer;
0256                if (peer != null) {
0257                    peer.setFont(f);
0258                }
0259            }
0260
0261            /**
0262             * Removes the menu component's peer.  The peer allows us to modify the
0263             * appearance of the menu component without changing the functionality of
0264             * the menu component.
0265             */
0266            public void removeNotify() {
0267                synchronized (getTreeLock()) {
0268                    MenuComponentPeer p = (MenuComponentPeer) this .peer;
0269                    if (p != null) {
0270                        Toolkit.getEventQueue().removeSourceEvents(this , true);
0271                        this .peer = null;
0272                        p.dispose();
0273                    }
0274                }
0275            }
0276
0277            /**
0278             * Posts the specified event to the menu.
0279             * This method is part of the Java&nbsp;1.0 event system
0280             * and it is maintained only for backwards compatibility.
0281             * Its use is discouraged, and it may not be supported
0282             * in the future.
0283             * @param evt the event which is to take place
0284             * @deprecated As of JDK version 1.1, replaced by {@link
0285             * #dispatchEvent(AWTEvent) dispatchEvent}.
0286             */
0287            @Deprecated
0288            public boolean postEvent(Event evt) {
0289                MenuContainer parent = this .parent;
0290                if (parent != null) {
0291                    parent.postEvent(evt);
0292                }
0293                return false;
0294            }
0295
0296            /**
0297             * Delivers an event to this component or one of its sub components.
0298             * @param e the event
0299             */
0300            public final void dispatchEvent(AWTEvent e) {
0301                dispatchEventImpl(e);
0302            }
0303
0304            void dispatchEventImpl(AWTEvent e) {
0305                EventQueue.setCurrentEventAndMostRecentTime(e);
0306
0307                Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);
0308
0309                if (newEventsOnly
0310                        || (parent != null && parent instanceof  MenuComponent && ((MenuComponent) parent).newEventsOnly)) {
0311                    if (eventEnabled(e)) {
0312                        processEvent(e);
0313                    } else if (e instanceof  ActionEvent && parent != null) {
0314                        e.setSource(parent);
0315                        ((MenuComponent) parent).dispatchEvent(e);
0316                    }
0317
0318                } else { // backward compatibility
0319                    Event olde = e.convertToOld();
0320                    if (olde != null) {
0321                        postEvent(olde);
0322                    }
0323                }
0324            }
0325
0326            // REMIND: remove when filtering is done at lower level
0327            boolean eventEnabled(AWTEvent e) {
0328                return false;
0329            }
0330
0331            /** 
0332             * Processes events occurring on this menu component.  
0333             * <p>Note that if the event parameter is <code>null</code>
0334             * the behavior is unspecified and may result in an
0335             * exception.
0336             *
0337             * @param e the event
0338             * @since JDK1.1
0339             */
0340            protected void processEvent(AWTEvent e) {
0341            }
0342
0343            /**
0344             * Returns a string representing the state of this
0345             * <code>MenuComponent</code>. This method is intended to be used
0346             * only for debugging purposes, and the content and format of the
0347             * returned string may vary between implementations. The returned
0348             * string may be empty but may not be <code>null</code>.
0349             *
0350             * @return     the parameter string of this menu component
0351             */
0352            protected String paramString() {
0353                String this Name = getName();
0354                return (this Name != null ? this Name : "");
0355            }
0356
0357            /**
0358             * Returns a representation of this menu component as a string. 
0359             * @return  a string representation of this menu component
0360             */
0361            public String toString() {
0362                return getClass().getName() + "[" + paramString() + "]";
0363            }
0364
0365            /**
0366             * Gets this component's locking object (the object that owns the thread 
0367             * sychronization monitor) for AWT component-tree and layout
0368             * operations.
0369             * @return this component's locking object
0370             */
0371            protected final Object getTreeLock() {
0372                return Component.LOCK;
0373            }
0374
0375            /**
0376             * Reads the menu component from an object input stream.
0377             *
0378             * @param s the <code>ObjectInputStream</code> to read
0379             * @exception HeadlessException if
0380             *   <code>GraphicsEnvironment.isHeadless</code> returns
0381             *   <code>true</code>
0382             * @serial
0383             * @see java.awt.GraphicsEnvironment#isHeadless
0384             */
0385            private void readObject(ObjectInputStream s)
0386                    throws ClassNotFoundException, IOException,
0387                    HeadlessException {
0388                GraphicsEnvironment.checkHeadless();
0389                s.defaultReadObject();
0390
0391                appContext = AppContext.getAppContext();
0392            }
0393
0394            /**
0395             * Initialize JNI field and method IDs.
0396             */
0397            private static native void initIDs();
0398
0399            /*
0400             * --- Accessibility Support ---
0401             *
0402             *  MenuComponent will contain all of the methods in interface Accessible,
0403             *  though it won't actually implement the interface - that will be up
0404             *  to the individual objects which extend MenuComponent.
0405             */
0406
0407            AccessibleContext accessibleContext = null;
0408
0409            /**
0410             * Gets the <code>AccessibleContext</code> associated with 
0411             * this <code>MenuComponent</code>.
0412             *
0413             * The method implemented by this base class returns <code>null</code>.
0414             * Classes that extend <code>MenuComponent</code>
0415             * should implement this method to return the 
0416             * <code>AccessibleContext</code> associated with the subclass.
0417             *
0418             * @return the <code>AccessibleContext</code> of this
0419             *     <code>MenuComponent</code>
0420             * @since 1.3
0421             */
0422            public AccessibleContext getAccessibleContext() {
0423                return accessibleContext;
0424            }
0425
0426            /**
0427             * Inner class of <code>MenuComponent</code> used to provide
0428             * default support for accessibility.  This class is not meant
0429             * to be used directly by application developers, but is instead
0430             * meant only to be subclassed by menu component developers.
0431             * <p>
0432             * The class used to obtain the accessible role for this object.
0433             * @since 1.3
0434             */
0435            protected abstract class AccessibleAWTMenuComponent extends
0436                    AccessibleContext implements  java.io.Serializable,
0437                    AccessibleComponent, AccessibleSelection {
0438                /*
0439                 * JDK 1.3 serialVersionUID
0440                 */
0441                private static final long serialVersionUID = -4269533416223798698L;
0442
0443                /**
0444                 * Although the class is abstract, this should be called by
0445                 * all sub-classes. 
0446                 */
0447                protected AccessibleAWTMenuComponent() {
0448                }
0449
0450                // AccessibleContext methods
0451                //
0452
0453                /**
0454                 * Gets the <code>AccessibleSelection</code> associated with this
0455                 * object which allows its <code>Accessible</code> children to be selected.
0456                 *
0457                 * @return <code>AccessibleSelection</code> if supported by object;
0458                 *      else return <code>null</code>
0459                 * @see AccessibleSelection
0460                 */
0461                public AccessibleSelection getAccessibleSelection() {
0462                    return this ;
0463                }
0464
0465                /**
0466                 * Gets the accessible name of this object.  This should almost never
0467                 * return <code>java.awt.MenuComponent.getName</code>, as that
0468                 * generally isn't a localized name, and doesn't have meaning for the
0469                 * user.  If the object is fundamentally a text object (e.g. a menu item), the
0470                 * accessible name should be the text of the object (e.g. "save").
0471                 * If the object has a tooltip, the tooltip text may also be an
0472                 * appropriate String to return.
0473                 *
0474                 * @return the localized name of the object -- can be <code>null</code>
0475                 *         if this object does not have a name
0476                 * @see AccessibleContext#setAccessibleName
0477                 */
0478                public String getAccessibleName() {
0479                    return accessibleName;
0480                }
0481
0482                /**
0483                 * Gets the accessible description of this object.  This should be
0484                 * a concise, localized description of what this object is - what
0485                 * is its meaning to the user.  If the object has a tooltip, the
0486                 * tooltip text may be an appropriate string to return, assuming
0487                 * it contains a concise description of the object (instead of just
0488                 * the name of the object - e.g. a "Save" icon on a toolbar that
0489                 * had "save" as the tooltip text shouldn't return the tooltip
0490                 * text as the description, but something like "Saves the current
0491                 * text document" instead).
0492                 *
0493                 * @return the localized description of the object -- can be
0494                 *     <code>null</code> if this object does not have a description
0495                 * @see AccessibleContext#setAccessibleDescription
0496                 */
0497                public String getAccessibleDescription() {
0498                    return accessibleDescription;
0499                }
0500
0501                /**
0502                 * Gets the role of this object.
0503                 *
0504                 * @return an instance of <code>AccessibleRole</code>
0505                 *     describing the role of the object
0506                 * @see AccessibleRole
0507                 */
0508                public AccessibleRole getAccessibleRole() {
0509                    return AccessibleRole.AWT_COMPONENT; // Non-specific -- overridden in subclasses
0510                }
0511
0512                /**
0513                 * Gets the state of this object.
0514                 *
0515                 * @return an instance of <code>AccessibleStateSet</code>
0516                 *     containing the current state set of the object
0517                 * @see AccessibleState
0518                 */
0519                public AccessibleStateSet getAccessibleStateSet() {
0520                    return MenuComponent.this .getAccessibleStateSet();
0521                }
0522
0523                /**
0524                 * Gets the <code>Accessible</code> parent of this object. 
0525                 * If the parent of this object implements <code>Accessible</code>,
0526                 * this method should simply return <code>getParent</code>.
0527                 *
0528                 * @return the <code>Accessible</code> parent of this object -- can
0529                 *    be <code>null</code> if this object does not have an 
0530                 *    <code>Accessible</code> parent
0531                 */
0532                public Accessible getAccessibleParent() {
0533                    if (accessibleParent != null) {
0534                        return accessibleParent;
0535                    } else {
0536                        MenuContainer parent = MenuComponent.this .getParent();
0537                        if (parent instanceof  Accessible) {
0538                            return (Accessible) parent;
0539                        }
0540                    }
0541                    return null;
0542                }
0543
0544                /**
0545                 * Gets the index of this object in its accessible parent.
0546                 *
0547                 * @return the index of this object in its parent; -1 if this
0548                 *     object does not have an accessible parent
0549                 * @see #getAccessibleParent
0550                 */
0551                public int getAccessibleIndexInParent() {
0552                    return MenuComponent.this .getAccessibleIndexInParent();
0553                }
0554
0555                /**
0556                 * Returns the number of accessible children in the object.  If all
0557                 * of the children of this object implement <code>Accessible</code>,
0558                 * then this method should return the number of children of this object.
0559                 *
0560                 * @return the number of accessible children in the object
0561                 */
0562                public int getAccessibleChildrenCount() {
0563                    return 0; // MenuComponents don't have children
0564                }
0565
0566                /**
0567                 * Returns the nth <code>Accessible</code> child of the object.
0568                 *
0569                 * @param i zero-based index of child
0570                 * @return the nth Accessible child of the object
0571                 */
0572                public Accessible getAccessibleChild(int i) {
0573                    return null; // MenuComponents don't have children
0574                }
0575
0576                /**
0577                 * Returns the locale of this object.
0578                 *
0579                 * @return the locale of this object
0580                 */
0581                public java.util.Locale getLocale() {
0582                    MenuContainer parent = MenuComponent.this .getParent();
0583                    if (parent instanceof  Component)
0584                        return ((Component) parent).getLocale();
0585                    else
0586                        return java.util.Locale.getDefault();
0587                }
0588
0589                /**
0590                 * Gets the <code>AccessibleComponent</code> associated with
0591                 * this object if one exists.  Otherwise return <code>null</code>.
0592                 *
0593                 * @return the component
0594                 */
0595                public AccessibleComponent getAccessibleComponent() {
0596                    return this ;
0597                }
0598
0599                // AccessibleComponent methods
0600                //
0601                /**
0602                 * Gets the background color of this object.
0603                 *
0604                 * @return the background color, if supported, of the object;
0605                 *     otherwise, <code>null</code>
0606                 */
0607                public Color getBackground() {
0608                    return null; // Not supported for MenuComponents
0609                }
0610
0611                /**
0612                 * Sets the background color of this object.
0613                 * (For transparency, see <code>isOpaque</code>.)
0614                 *
0615                 * @param c the new <code>Color</code> for the background
0616                 * @see Component#isOpaque
0617                 */
0618                public void setBackground(Color c) {
0619                    // Not supported for MenuComponents
0620                }
0621
0622                /**
0623                 * Gets the foreground color of this object.
0624                 *
0625                 * @return the foreground color, if supported, of the object;
0626                 *     otherwise, <code>null</code>
0627                 */
0628                public Color getForeground() {
0629                    return null; // Not supported for MenuComponents
0630                }
0631
0632                /**
0633                 * Sets the foreground color of this object.
0634                 *
0635                 * @param c the new <code>Color</code> for the foreground
0636                 */
0637                public void setForeground(Color c) {
0638                    // Not supported for MenuComponents
0639                }
0640
0641                /**
0642                 * Gets the <code>Cursor</code> of this object.
0643                 *
0644                 * @return the <code>Curso</code>, if supported, of the object;
0645                 *     otherwise, <code>null</code>
0646                 */
0647                public Cursor getCursor() {
0648                    return null; // Not supported for MenuComponents
0649                }
0650
0651                /**
0652                 * Sets the <code>Cursor</code> of this object.
0653                 * <p>
0654                 * The method may have no visual effect if the Java platform
0655                 * implementation and/or the native system do not support
0656                 * changing the mouse cursor shape.
0657                 * @param cursor the new <code>Cursor</code> for the object
0658                 */
0659                public void setCursor(Cursor cursor) {
0660                    // Not supported for MenuComponents
0661                }
0662
0663                /**
0664                 * Gets the <code>Font</code> of this object.
0665                 *
0666                 * @return the <code>Font</code>,if supported, for the object;
0667                 *     otherwise, <code>null</code>
0668                 */
0669                public Font getFont() {
0670                    return MenuComponent.this .getFont();
0671                }
0672
0673                /**
0674                 * Sets the <code>Font</code> of this object.
0675                 *
0676                 * @param f the new <code>Font</code> for the object
0677                 */
0678                public void setFont(Font f) {
0679                    MenuComponent.this .setFont(f);
0680                }
0681
0682                /**
0683                 * Gets the <code>FontMetrics</code> of this object.
0684                 *
0685                 * @param f the <code>Font</code>
0686                 * @return the FontMetrics, if supported, the object;
0687                 *		otherwise, <code>null</code>
0688                 * @see #getFont
0689                 */
0690                public FontMetrics getFontMetrics(Font f) {
0691                    return null; // Not supported for MenuComponents
0692                }
0693
0694                /**
0695                 * Determines if the object is enabled.
0696                 *
0697                 * @return true if object is enabled; otherwise, false
0698                 */
0699                public boolean isEnabled() {
0700                    return true; // Not supported for MenuComponents
0701                }
0702
0703                /**
0704                 * Sets the enabled state of the object.
0705                 *
0706                 * @param b if true, enables this object; otherwise, disables it
0707                 */
0708                public void setEnabled(boolean b) {
0709                    // Not supported for MenuComponents
0710                }
0711
0712                /**
0713                 * Determines if the object is visible.  Note: this means that the
0714                 * object intends to be visible; however, it may not in fact be
0715                 * showing on the screen because one of the objects that this object
0716                 * is contained by is not visible.  To determine if an object is
0717                 * showing on the screen, use <code>isShowing</code>.
0718                 *
0719                 * @return true if object is visible; otherwise, false
0720                 */
0721                public boolean isVisible() {
0722                    return true; // Not supported for MenuComponents
0723                }
0724
0725                /**
0726                 * Sets the visible state of the object.
0727                 *
0728                 * @param b if true, shows this object; otherwise, hides it
0729                 */
0730                public void setVisible(boolean b) {
0731                    // Not supported for MenuComponents
0732                }
0733
0734                /**
0735                 * Determines if the object is showing.  This is determined by checking
0736                 * the visibility of the object and ancestors of the object.  Note:
0737                 * this will return true even if the object is obscured by another
0738                 * (for example, it happens to be underneath a menu that was pulled
0739                 * down).
0740                 *
0741                 * @return true if object is showing; otherwise, false
0742                 */
0743                public boolean isShowing() {
0744                    return true; // Not supported for MenuComponents
0745                }
0746
0747                /**
0748                 * Checks whether the specified point is within this object's bounds,
0749                 * where the point's x and y coordinates are defined to be relative to
0750                 * the coordinate system of the object.
0751                 *
0752                 * @param p the <code>Point</code> relative to the coordinate
0753                 *     system of the object
0754                 * @return true if object contains <code>Point</code>; otherwise false
0755                 */
0756                public boolean contains(Point p) {
0757                    return false; // Not supported for MenuComponents
0758                }
0759
0760                /**
0761                 * Returns the location of the object on the screen.
0762                 *
0763                 * @return location of object on screen -- can be <code>null</code>
0764                 *     if this object is not on the screen
0765                 */
0766                public Point getLocationOnScreen() {
0767                    return null; // Not supported for MenuComponents
0768                }
0769
0770                /**
0771                 * Gets the location of the object relative to the parent in the form
0772                 * of a point specifying the object's top-left corner in the screen's
0773                 * coordinate space.
0774                 *
0775                 * @return an instance of <code>Point</code> representing the
0776                 *    top-left corner of the object's bounds in the coordinate
0777                 *    space of the screen; <code>null</code> if
0778                 *    this object or its parent are not on the screen
0779                 */
0780                public Point getLocation() {
0781                    return null; // Not supported for MenuComponents
0782                }
0783
0784                /**
0785                 * Sets the location of the object relative to the parent.
0786                 */
0787                public void setLocation(Point p) {
0788                    // Not supported for MenuComponents
0789                }
0790
0791                /**
0792                 * Gets the bounds of this object in the form of a
0793                 * <code>Rectangle</code> object.
0794                 * The bounds specify this object's width, height, and location
0795                 * relative to its parent.
0796                 *
0797                 * @return a rectangle indicating this component's bounds;
0798                 *     <code>null</code> if this object is not on the screen
0799                 */
0800                public Rectangle getBounds() {
0801                    return null; // Not supported for MenuComponents
0802                }
0803
0804                /**
0805                 * Sets the bounds of this object in the form of a
0806                 * <code>Rectangle</code> object.
0807                 * The bounds specify this object's width, height, and location
0808                 * relative to its parent.
0809                 *
0810                 * @param r a rectangle indicating this component's bounds
0811                 */
0812                public void setBounds(Rectangle r) {
0813                    // Not supported for MenuComponents
0814                }
0815
0816                /**
0817                 * Returns the size of this object in the form of a
0818                 * <code>Dimension</code> object. The height field of
0819                 * the <code>Dimension</code> object contains this object's
0820                 * height, and the width field of the <code>Dimension</code>
0821                 * object contains this object's width.
0822                 *
0823                 * @return a <code>Dimension</code> object that indicates the
0824                 *         size of this component; <code>null</code>
0825                 *         if this object is not on the screen
0826                 */
0827                public Dimension getSize() {
0828                    return null; // Not supported for MenuComponents
0829                }
0830
0831                /**
0832                 * Resizes this object.
0833                 *
0834                 * @param d - the <code>Dimension</code> specifying the
0835                 *    new size of the object
0836                 */
0837                public void setSize(Dimension d) {
0838                    // Not supported for MenuComponents
0839                }
0840
0841                /**
0842                 * Returns the <code>Accessible</code> child, if one exists,
0843                 * contained at the local coordinate <code>Point</code>.
0844                 * If there is no <code>Accessible</code> child, <code>null</code>
0845                 * is returned.
0846                 *
0847                 * @param p the point defining the top-left corner of the 
0848                 *    <code>Accessible</code>, given in the coordinate space
0849                 *    of the object's parent
0850                 * @return the <code>Accessible</code>, if it exists,
0851                 *    at the specified location; else <code>null</code>
0852                 */
0853                public Accessible getAccessibleAt(Point p) {
0854                    return null; // MenuComponents don't have children
0855                }
0856
0857                /**
0858                 * Returns whether this object can accept focus or not.
0859                 *
0860                 * @return true if object can accept focus; otherwise false
0861                 */
0862                public boolean isFocusTraversable() {
0863                    return true; // Not supported for MenuComponents
0864                }
0865
0866                /**
0867                 * Requests focus for this object.
0868                 */
0869                public void requestFocus() {
0870                    // Not supported for MenuComponents
0871                }
0872
0873                /**
0874                 * Adds the specified focus listener to receive focus events from this
0875                 * component.
0876                 *
0877                 * @param l the focus listener
0878                 */
0879                public void addFocusListener(java.awt.event.FocusListener l) {
0880                    // Not supported for MenuComponents
0881                }
0882
0883                /**
0884                 * Removes the specified focus listener so it no longer receives focus
0885                 * events from this component.
0886                 *
0887                 * @param l the focus listener
0888                 */
0889                public void removeFocusListener(java.awt.event.FocusListener l) {
0890                    // Not supported for MenuComponents
0891                }
0892
0893                // AccessibleSelection methods
0894                //
0895
0896                /**
0897                 * Returns the number of <code>Accessible</code> children currently selected.
0898                 * If no children are selected, the return value will be 0.
0899                 *
0900                 * @return the number of items currently selected
0901                 */
0902                public int getAccessibleSelectionCount() {
0903                    return 0; //  To be fully implemented in a future release
0904                }
0905
0906                /**
0907                 * Returns an <code>Accessible</code> representing the specified 
0908                 * selected child in the object.  If there isn't a selection, or there are
0909                 * fewer children selected than the integer passed in, the return
0910                 * value will be <code>null</code>.
0911                 * <p>Note that the index represents the i-th selected child, which
0912                 * is different from the i-th child.
0913                 *
0914                 * @param i the zero-based index of selected children
0915                 * @return the i-th selected child
0916                 * @see #getAccessibleSelectionCount
0917                 */
0918                public Accessible getAccessibleSelection(int i) {
0919                    return null; //  To be fully implemented in a future release
0920                }
0921
0922                /**
0923                 * Determines if the current child of this object is selected.
0924                 *
0925                 * @return true if the current child of this object is selected; 
0926                 *    else false
0927                 * @param i the zero-based index of the child in this 
0928                 *      <code>Accessible</code> object
0929                 * @see AccessibleContext#getAccessibleChild
0930                 */
0931                public boolean isAccessibleChildSelected(int i) {
0932                    return false; //  To be fully implemented in a future release
0933                }
0934
0935                /**
0936                 * Adds the specified <code>Accessible</code> child of the object
0937                 * to the object's selection.  If the object supports multiple selections,
0938                 * the specified child is added to any existing selection, otherwise
0939                 * it replaces any existing selection in the object.  If the
0940                 * specified child is already selected, this method has no effect.
0941                 *
0942                 * @param i the zero-based index of the child
0943                 * @see AccessibleContext#getAccessibleChild
0944                 */
0945                public void addAccessibleSelection(int i) {
0946                    //  To be fully implemented in a future release
0947                }
0948
0949                /**
0950                 * Removes the specified child of the object from the object's
0951                 * selection.  If the specified item isn't currently selected, this
0952                 * method has no effect.
0953                 *
0954                 * @param i the zero-based index of the child
0955                 * @see AccessibleContext#getAccessibleChild
0956                 */
0957                public void removeAccessibleSelection(int i) {
0958                    //  To be fully implemented in a future release
0959                }
0960
0961                /**
0962                 * Clears the selection in the object, so that no children in the
0963                 * object are selected.
0964                 */
0965                public void clearAccessibleSelection() {
0966                    //  To be fully implemented in a future release
0967                }
0968
0969                /**
0970                 * Causes every child of the object to be selected
0971                 * if the object supports multiple selections.
0972                 */
0973                public void selectAllAccessibleSelection() {
0974                    //  To be fully implemented in a future release
0975                }
0976
0977            } // inner class AccessibleAWTComponent
0978
0979            /**
0980             * Gets the index of this object in its accessible parent.
0981             *
0982             * @return -1 if this object does not have an accessible parent;
0983             *      otherwise, the index of the child in its accessible parent.
0984             */
0985            int getAccessibleIndexInParent() {
0986                MenuContainer localParent = parent;
0987                if (!(localParent instanceof  MenuComponent)) {
0988                    // MenuComponents only have accessible index when inside MenuComponents
0989                    return -1;
0990                }
0991                MenuComponent localParentMenu = (MenuComponent) localParent;
0992                return localParentMenu.getAccessibleChildIndex(this );
0993            }
0994
0995            /**
0996             * Gets the index of the child within this MenuComponent.
0997             *
0998             * @param child MenuComponent whose index we are interested in.
0999             * @return -1 if this object doesn't contain the child,
1000             *      otherwise, index of the child.
1001             */
1002            int getAccessibleChildIndex(MenuComponent child) {
1003                return -1; // Overridden in subclasses.
1004            }
1005
1006            /**
1007             * Gets the state of this object.
1008             *
1009             * @return an instance of <code>AccessibleStateSet</code>
1010             *     containing the current state set of the object
1011             * @see AccessibleState
1012             */
1013            AccessibleStateSet getAccessibleStateSet() {
1014                AccessibleStateSet states = new AccessibleStateSet();
1015                return states;
1016            }
1017
1018        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.