/[classpath]/classpath/java/awt/MenuComponent.java
ViewVC logotype

Diff of /classpath/java/awt/MenuComponent.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by uid67440, Fri Dec 26 16:37:27 2003 UTC revision 1.15 by gnu_andrew, Sat Sep 11 12:18:06 2004 UTC
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.awt;  package java.awt;
40    
41    import java.awt.event.FocusEvent;
42    import java.awt.event.FocusListener;
43  import java.awt.peer.MenuComponentPeer;  import java.awt.peer.MenuComponentPeer;
44  import java.io.Serializable;  import java.io.Serializable;
45    import java.util.Locale;
46  // FIXME: Java 1.0 event model unimplemented  import javax.accessibility.Accessible;
47    import javax.accessibility.AccessibleComponent;
48    import javax.accessibility.AccessibleContext;
49    import javax.accessibility.AccessibleRole;
50    import javax.accessibility.AccessibleSelection;
51    import javax.accessibility.AccessibleStateSet;
52    
53  /**  /**
54    * This is the superclass of all non-menu AWT widgets.    * This is the superclass of all menu AWT widgets.
55    *    *
56    * @author Aaron M. Renn (arenn@urbanophile.com)    * @author Aaron M. Renn (arenn@urbanophile.com)
57      * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
58    */    */
59  public abstract class MenuComponent implements Serializable  public abstract class MenuComponent implements Serializable
60  {  {
# Line 59  public abstract class MenuComponent impl Line 67  public abstract class MenuComponent impl
67  private static final long serialVersionUID = -4536902356223894379L;  private static final long serialVersionUID = -4536902356223894379L;
68    
69  /*************************************************************************/  /*************************************************************************/
70      
71  /*  /*
72   * Instance Variables   * Instance Variables
73   */   */
74    
75    // FIXME: missing serialized fields `nameExplicitlySet',  /**
76    // `newEventsOnly', and `accessibleContext'.   * The font for this component.
77     *
78  // The font for this component   * @see #getFont()
79  private Font font;   * @see #setFont(java.awt.Font)
80     * @serial the component's font.
81  // The name of the component   */
82  private String name;    private Font font;
   
 // The parent of this component  
 transient MenuContainer parent;  
   
 // The native peer for this componet  
 transient MenuComponentPeer peer;  
   
 // The synchronization locking object for this component  
 private transient Object tree_lock = this;  
83    
84  // The toolkit for this object    /**
85  private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();     * The name of the component.
86       *
87       * @see #getName()
88       * @see #setName(String)
89       * @serial the component's name.
90       */
91      private String name;
92    
93      /**
94       * The parent of this component.
95       *
96       * @see #getParent()
97       * @see #setParent(java.awt.MenuContainer)
98       * @serial ignored.
99       */
100      transient MenuContainer parent;
101    
102      /**
103       * The native peer for this component.
104       *
105       * @see #getPeer()
106       * @see #setPeer(java.awt.peer.MenuComponentPeer)
107       * @serial ignored.
108       */
109      transient MenuComponentPeer peer;
110    
111      /**
112       * The synchronization locking object for this component.
113       *
114       * @serial ignored.
115       */
116      private transient Object tree_lock = this;
117    
118      /**
119       * The toolkit for this object.
120       *
121       * @see #getToolkit()
122       * @serial ignored.
123       */
124      private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
125    
126      /**
127       * The accessible context for this component.
128       *
129       * @see #getAccessibleContext()
130       * @serial the accessibility information for this component.
131       */
132      private AccessibleContext accessibleContext;
133    
134      /**
135       * Was the name of the component set?  This value defaults
136       * to false and becomes true after a call to <code>setName()</code>.
137       * Please note that this does not guarantee that name will then
138       * be non-null, as this may be the value passed to <code>setName()</code>.
139       *
140       * @see #setName(String)
141       * @serial true if the name value has been explicitly set by calling
142       *         <code>setName()</code>.
143       */
144      private boolean nameExplicitlySet;
145    
146      /**
147       * Does this component handle new events?  Events will be handled
148       * by this component if this is true.  Otherwise, they will be forwarded
149       * up the component hierarchy.  This implementation does not use this
150       * variable; it is merely provided for serialization compatability.
151       *
152       * @see #dispatchEvent(AWTEvent)
153       * @serial true if events are to be processed locally.
154       */
155      private boolean newEventsOnly;
156    
157      /**
158       * The focus listener chain handler which deals with focus events for
159       * the accessible context of this component.
160       *
161       * @see AccessibleAWTMenuComponent#addFocusListener(java.awt.event.FocusListener)
162       * @serial ignored.
163       */
164      private transient FocusListener focusListener;
165    
166  /*************************************************************************/  /*************************************************************************/
167    
# Line 157  public void Line 235  public void
235  setName(String name)  setName(String name)
236  {  {
237    this.name = name;    this.name = name;
238      nameExplicitlySet = true;
239  }  }
240    
241  /*************************************************************************/  /*************************************************************************/
# Line 260  setTreeLock(Object tree_lock) Line 339  setTreeLock(Object tree_lock)
339    * AWT 1.0 event dispatcher.    * AWT 1.0 event dispatcher.
340    *    *
341    * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.    * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
342      * @return true if the event was dispatched, false otherwise.
343    */    */
344  public boolean  public boolean
345  postEvent(Event event)  postEvent(Event event)
346  {  {
347    return(false);    // This is overridden by subclasses that support events.
348      return false;
349  }  }
   
350  /*************************************************************************/  /*************************************************************************/
351    
352  /**  /**
# Line 274  postEvent(Event event) Line 354  postEvent(Event event)
354    *    *
355    * @param event The event to dispatch    * @param event The event to dispatch
356    */    */
357  public final void  public final void dispatchEvent(AWTEvent event)
 dispatchEvent(AWTEvent event)  
358  {  {
359    // See comment in Component.dispatchEvent().    // See comment in Component.dispatchEvent().
360    dispatchEventImpl(event);    dispatchEventImpl(event);
361  }  }
362    
363  void  
364  dispatchEventImpl(AWTEvent e)  /**
365     * Implementation of dispatchEvent. Allows trusted package classes
366     * to dispatch additional events first.  This implementation first
367     * translates <code>event</code> to an AWT 1.0 event and sends the
368     * result to {@link #postEvent}.  The event is then
369     * passed on to {@link #processEvent} for local processing.
370     *
371     * @param event the event to dispatch.
372     */
373    void dispatchEventImpl(AWTEvent event)
374  {  {
375      Event oldStyleEvent;
376    
377    // This is overridden by subclasses that support events.    // This is overridden by subclasses that support events.
378      /* Convert AWT 1.1 event to AWT 1.0 event */
379      oldStyleEvent = Component.translateEvent(event);
380      if (oldStyleEvent != null)
381        {
382          postEvent(oldStyleEvent);
383        }
384      /* Do local processing */
385      processEvent(event);
386  }  }
387    
388  /*************************************************************************/  /*************************************************************************/
# Line 298  dispatchEventImpl(AWTEvent e) Line 396  dispatchEventImpl(AWTEvent e)
396  protected void  protected void
397  processEvent(AWTEvent event)  processEvent(AWTEvent event)
398  {  {
399      /*
400         Pass a focus event to the focus listener for
401         the accessibility context.
402      */
403      if (event instanceof FocusEvent)
404        {
405          if (focusListener != null)
406            {
407              switch (event.id)
408                {
409                case FocusEvent.FOCUS_GAINED:
410                  focusListener.focusGained((FocusEvent) event);
411                  break;
412                case FocusEvent.FOCUS_LOST:
413                  focusListener.focusLost((FocusEvent) event);
414                  break;
415                }
416            }
417        }
418  }  }
419    
420  /*************************************************************************/  /*************************************************************************/
# Line 316  toString() Line 433  toString()
433  /*************************************************************************/  /*************************************************************************/
434    
435  /**  /**
436    * Returns a debugging string for this component   * Returns a debugging string for this component
437    */   */
438  protected String  protected String
439  paramString()  paramString()
440  {  {
441    return "name=" + getName();    return "name=" + getName();
442  }  }
443    
444  // Accessibility API not yet implemented.  /**
445  // public AccessibleContext getAccessibleContext()   * Gets the AccessibleContext associated with this <code>MenuComponent</code>.
446     * As an abstract class, we return null.  Concrete subclasses should return
447     * their implementation of the accessibility context.
448     *
449     * @return null.
450     */
451    
452    public AccessibleContext getAccessibleContext()
453    {
454      return null;
455    }
456    
457    /**
458     * This class provides a base for the accessibility support of menu
459     * components.
460     *
461     * @author Andrew John Hughes <gnu_andrew@member.fsf.org>
462     */
463    protected abstract class AccessibleAWTMenuComponent
464      extends AccessibleContext
465      implements Serializable, AccessibleComponent, AccessibleSelection
466    {
467    
468      /**
469       * Compatible with JDK 1.4.2 revision 5
470       */
471      private static final long serialVersionUID = -4269533416223798698L;
472    
473      /**
474       * This is the default constructor.  It should be called by
475       * concrete subclasses to ensure necessary groundwork is completed.
476       */
477      protected AccessibleAWTMenuComponent()
478      {
479      }
480    
481      /**
482       * Replaces or supplements the component's selection with the
483       * <code>Accessible</code> child at the supplied index.  If
484       * the component supports multiple selection, the child is
485       * added to the current selection.  Otherwise, the current
486       * selection becomes the specified child.  If the child is
487       * already selected, nothing happens.
488       * <br />
489       * <br />
490       * As the existence of children can not be determined from
491       * this abstract class, the implementation of this method
492       * is left to subclasses.
493       *
494       * @param index the index of the specified child within a
495       *        zero-based list of the component's children.
496       */
497      public void addAccessibleSelection(int index)
498      {
499        /* Subclasses with children should implement this */
500      }
501    
502      /**
503       * Registers the specified focus listener to receive
504       * focus events from this component.
505       *
506       * @param listener the new focus listener.
507       */
508      public void addFocusListener(FocusListener listener)
509      {
510        /*
511         * Chain the new focus listener to the existing chain
512         * of focus listeners.  Each new focus listener is
513         * coupled via multicasting to the existing chain.
514         */
515        focusListener = AWTEventMulticaster.add(focusListener, listener);
516      }
517    
518      /**
519       * Clears the component's current selection.  Following
520       * the calling of this method, no children of the component
521       * will be selected.
522       * <br />
523       * <br />
524       * As the existence of children can not be determined from
525       * this abstract class, the implementation of this method
526       * is left to subclasses.
527       */
528      public void clearAccessibleSelection()
529      {
530      }
531    
532      /**
533       * Returns true if the specified point lies within the
534       * component.  The supplied co-ordinates are assumed to
535       * be relative to the co-ordinate system of the component
536       * itself.  Thus, the point (0,0) is the upper left corner
537       * of this component.
538       * <br />
539       * <br />
540       * Please note that this method depends on a correctly implemented
541       * version of the <code>getBounds()</code> method.  Subclasses
542       * must provide the bounding rectangle via <code>getBounds()</code>
543       * in order for this method to work.  
544       *
545       * @param point the point to check against this component.
546       * @return true if the point is within this component.
547       * @see #getBounds()
548       */
549      public boolean contains(Point point)
550      {
551        /*
552           We can simply return the result of a
553           test for containment in the bounding rectangle
554        */
555        return getBounds().contains(point);
556      }
557    
558      /**
559       * Returns the <code>Accessible</code> child of this component present
560       * at the specified point.  The supplied co-ordinates are
561       * assumed to be relative to the co-ordinate system of this
562       * component (the parent of any returned accessible).  Thus,
563       * the point (0,0) is the upper left corner of this menu
564       * component.
565       * <br />
566       * <br />
567       * As the existence of children can not be determined from
568       * this abstract class, the implementation of this method
569       * is left to subclasses.
570       *
571       * @param point the point at which the returned accessible
572       *        is located.
573       * @return null.
574       */
575      public Accessible getAccessibleAt(Point point)
576      {
577        return null;
578      }
579    
580      /**
581       * Returns the <code>Accessible</code> child at the supplied
582       * index within the list of children of this component.
583       * <br />
584       * <br />
585       * As the existence of children can not be determined from
586       * this abstract class, the implementation of this method
587       * is left to subclasses.
588       *
589       * @param index the index of the <code>Accessible</code> child
590       *        to retrieve.
591       * @return null.
592       */
593      public Accessible getAccessibleChild(int index)
594      {
595        return null;
596      }
597    
598      /**
599       * Returns the number of children of this component which
600       * implement the <code>Accessible</code> interface.  If
601       * all children of this component are accessible, then
602       * the returned value will be the same as the number of
603       * children.
604       * <br />
605       * <br />
606       *
607       * @return 0.
608       */
609      public int getAccessibleChildrenCount()
610      {
611        return 0;
612      }
613    
614      /**
615       * Retrieves the <code>AccessibleComponent</code> associated
616       * with this accessible context and its component.  As the
617       * context itself implements <code>AccessibleComponent</code>,
618       * this is the return value.
619       *
620       * @return the context itself.
621       */
622      public AccessibleComponent getAccessibleComponent()
623      {
624        return this;
625      }
626    
627      /**
628       * Returns the accessible name for this menu component.  This
629       * is the name given to the component, which may be null if
630       * not set using <code>setName()</code>.
631       * <br />
632       * <br />
633       * The name is not the most appropriate description of this
634       * object.  Subclasses should preferably provide a more
635       * accurate description.  For example, a File menu could
636       * have the description `Lists commands related to the
637       * file system'.
638       *
639       * @return a description of the component.  Currently,
640       *         this is just the contents of the name property.
641       * @see MenuComponent#setName(String)
642       */
643      public String getAccessibleDescription()
644      {
645        return MenuComponent.this.getName();
646      }
647    
648      /**
649       * Retrieves the index of this component within its parent.
650       * If no parent exists, -1 is returned.
651       *
652       * @return -1 as the parent, a <code>MenuContainer</code>
653       *         is not <code>Accessible</code>.
654       */
655      public int getAccessibleIndexInParent()
656      {
657        return -1;
658      }
659    
660      /**
661       * Returns the accessible name of this component.  This
662       * is the name given to the component, which may be null if
663       * not set using <code>setName()</code>.
664       * <br />
665       * <br />
666       * The name property is not the most suitable string to return
667       * for this method.  The string should be localized, and
668       * relevant to the operation of the component.  For example,
669       * it could be the text of a menu item.  However, this can
670       * not be used at this level of abstraction, so it is the
671       * responsibility of subclasses to provide a more appropriate
672       * name.
673       *
674       * @return a localized name for this component.  Currently, this
675       *         is just the contents of the name property.
676       * @see MenuComponent#setName(String)
677       */
678      public String getAccessibleName()
679      {
680        return MenuComponent.this.getName();
681      }
682    
683      /**
684       * Returns the <code>Accessible</code> parent of this component.
685       * As the parent of a <code>MenuComponent</code> is a
686       * <code>MenuContainer</code>, which doesn't implement
687       * <code>Accessible</code>, this method returns null.
688       *
689       * @return null.
690       */
691      public Accessible getAccessibleParent()
692      {
693        return null;
694      }
695    
696      /**
697       * Returns the accessible role of this component.
698       * <br />
699       * <br />
700       * The abstract implementation of this method returns
701       * <code>AccessibleRole.AWT_COMPONENT</code>,
702       * as the abstract component has no specific role.  This
703       * method should be overridden by concrete subclasses, so
704       * as to return an appropriate role for the component.
705       *
706       * @return <code>AccessibleRole.AWT_COMPONENT</code>.
707       */
708      public AccessibleRole getAccessibleRole()
709      {
710        return AccessibleRole.AWT_COMPONENT;
711      }
712    
713      /**
714       * Retrieves the <code>AccessibleSelection</code> associated
715       * with this accessible context and its component.  As the
716       * context itself implements <code>AccessibleSelection</code>,
717       * this is the return value.
718       *
719       * @return the context itself.
720       */
721      public AccessibleSelection getAccessibleSelection()
722      {
723        return this;
724      }
725    
726      /**
727       * Retrieves the <code>Accessible</code> selected child
728       * at the specified index.  If there are no selected children
729       * or the index is outside the range of selected children,
730       * null is returned.  Please note that the index refers
731       * to the index of the child in the list of <strong>selected
732       * children</strong>, and not the index of the child in
733       * the list of all <code>Accessible</code> children.
734       * <br />
735       * <br />
736       * As the existence of children can not be determined from
737       * this abstract class, the implementation of this method
738       * is left to subclasses.
739       *
740       * @param index the index of the selected <code>Accessible</code>
741       *        child.
742       */
743      public Accessible getAccessibleSelection(int index)
744      {
745        return null;
746      }
747    
748      /**
749       * Returns a count of the number of <code>Accessible</code>
750       * children of this component which are currently selected.
751       * If there are no children currently selected, 0 is returned.
752       * <br />
753       * <br />
754       * As the existence of children can not be determined from
755       * this abstract class, the implementation of this method
756       * is left to subclasses.
757       *
758       * @return 0.
759       */
760      public int getAccessibleSelectionCount()
761      {
762        return 0;
763      }
764    
765      /**
766       * Retrieves the current state of this component
767       * in an accessible form.  For example, a given component
768       * may be visible, selected, disabled, etc.
769       * <br />
770       * <br />
771       * As this class tells us virtually nothing about the component,
772       * except for its name and font, no state information can be
773       * provided.  This implementation thus returns an empty
774       * state set, and it is left to concrete subclasses to provide
775       * a more acceptable and relevant state set.  Changes to these
776       * properties also need to be handled using
777       * <code>PropertyChangeListener</code>s.
778       *
779       * @return an empty <code>AccessibleStateSet</code>.
780       */
781      public AccessibleStateSet getAccessibleStateSet()
782      {
783        return new AccessibleStateSet();
784      }
785    
786      /**
787       * Returns the background color of the component, or null
788       * if this property is unsupported.
789       * <br />
790       * <br />
791       * This abstract class knows nothing about how the component
792       * is drawn on screen, so this method simply returns the
793       * default system background color used for rendering menus.
794       * Concrete subclasses which handle the drawing of an onscreen
795       * menu component should override this method and provide
796       * the appropriate information.
797       *
798       * @return the default system background color for menus.
799       * @see #setBackground(java.awt.Color)
800       */
801      public Color getBackground()
802      {
803        return SystemColor.menu;
804      }
805    
806      /**
807       * Returns a <code>Rectangle</code> which represents the
808       * bounds of this component.  The returned rectangle has the
809       * height and width of the component's bounds, and is positioned
810       * at a location relative to this component's parent, the
811       * <code>MenuContainer</code>.  null is returned if bounds
812       * are not supported by the component.
813       * <br />
814       * <br />
815       * This abstract class knows nothing about how the component
816       * is drawn on screen, so this method simply returns null.
817       * Concrete subclasses which handle the drawing of an onscreen
818       * menu component should override this method and provide
819       * the appropriate information.
820       *
821       * @return null.
822       * @see #setBounds(java.awt.Rectangle)
823       */
824      public Rectangle getBounds()
825      {
826        return null;
827      }
828    
829      /**
830       * Returns the <code>Cursor</code> displayed when the pointer
831       * is positioned over this component.  Alternatively, null
832       * is returned if the component doesn't support the cursor
833       * property.
834       * <br />
835       * <br />
836       * This abstract class knows nothing about how the component
837       * is drawn on screen, so this method simply returns the default
838       * system cursor.  Concrete subclasses which handle the drawing
839       * of an onscreen menu component may override this method and provide
840       * the appropriate information.
841       *
842       * @return the default system cursor.
843       * @see #setCursor(java.awt.Cursor)
844       */
845      public Cursor getCursor()
846      {
847        return Cursor.getDefaultCursor();
848      }
849    
850      /**
851       * Returns the <code>Font</code> used for text created by this component.
852       *
853       * @return the current font.
854       * @see #setFont(java.awt.Font)
855       */
856      public Font getFont()
857      {
858        return MenuComponent.this.getFont();
859      }
860    
861      /**
862       * Retrieves information on the rendering and metrics of the supplied
863       * font.  If font metrics are not supported by this component, null
864       * is returned.
865       * <br />
866       * <br />
867       * The abstract implementation of this method simply uses the toolkit
868       * to obtain the <code>FontMetrics</code>.  Concrete subclasses may
869       * find it more efficient to invoke their peer class directly, if one
870       * is available.
871       *
872       * @param font the font about which to retrieve rendering and metric
873       *        information.
874       * @return the metrics of the given font, as provided by the system
875       *         toolkit.
876       * @throws NullPointerException if the supplied font was null.
877       */
878      public FontMetrics getFontMetrics(Font font)
879      {
880        return MenuComponent.this.getToolkit().getFontMetrics(font);
881      }
882    
883      /**
884       * Returns the foreground color of the component, or null
885       * if this property is unsupported.
886       * <br />
887       * <br />
888       * This abstract class knows nothing about how the component
889       * is drawn on screen, so this method simply returns the
890       * default system text color used for rendering menus.
891       * Concrete subclasses which handle the drawing of an onscreen
892       * menu component should override this method and provide
893       * the appropriate information.
894       *
895       * @return the default system text color for menus.
896       * @see #setForeground(java.awt.Color)
897       */
898      public Color getForeground()
899      {
900        return SystemColor.menuText;
901      }
902    
903      /**
904       * Returns the locale currently in use by this component.
905       * <br />
906       * <br />
907       * This abstract class has no property relating to the
908       * locale used by the component, so this method simply
909       * returns the default locale for the current instance
910       * of the Java Virtual Machine (JVM).  Concrete subclasses
911       * which maintain such a property should override this method
912       * and provide the locale information more accurately.
913       *
914       * @return the default locale for this JVM instance.
915       */
916      public Locale getLocale()
917      {
918        return Locale.getDefault();
919      }
920    
921      /**
922       * Returns the location of the component, with co-ordinates
923       * relative to the parent component and using the co-ordinate
924       * space of the screen.  Thus, the point (0,0) is the upper
925       * left corner of the parent component.
926       * <br />
927       * <br />
928       * Please note that this method depends on a correctly implemented
929       * version of the <code>getBounds()</code> method.  Subclasses
930       * must provide the bounding rectangle via <code>getBounds()</code>
931       * in order for this method to work.  
932       *
933       * @return the location of the component, relative to its parent.
934       * @see #setLocation(java.awt.Point)
935       */
936      public Point getLocation()
937      {
938        /* Simply return the location of the bounding rectangle */
939        return getBounds().getLocation();
940      }
941    
942      /**
943       * Returns the location of the component, with co-ordinates
944       * relative to the screen.  Thus, the point (0,0) is the upper
945       * left corner of the screen.  null is returned if the component
946       * is either not on screen or if this property is unsupported.
947       * <br />
948       * <br />
949       * This abstract class knows nothing about how the component
950       * is drawn on screen, so this method simply returns null.
951       * Concrete subclasses which handle the drawing of an onscreen
952       * menu component should override this method and provide
953       * the appropriate information.
954       *
955       * @return the location of the component, relative to the screen.
956       */
957      public Point getLocationOnScreen()
958      {
959        return null;
960      }
961    
962      /**
963       * Returns the size of the component.
964       * <br />
965       * <br />
966       * Please note that this method depends on a correctly implemented
967       * version of the <code>getBounds()</code> method.  Subclasses
968       * must provide the bounding rectangle via <code>getBounds()</code>
969       * in order for this method to work.  
970       *
971       * @return the size of the component.
972       * @see #setSize(java.awt.Dimension)
973       */
974      public Dimension getSize()
975      {
976        /* Simply return the size of the bounding rectangle */
977        return getBounds().getSize();
978      }
979    
980      /**
981       * Returns true if the accessible child specified by the supplied index
982       * is currently selected.
983       * <br />
984       * <br />
985       * As the existence of children can not be determined from
986       * this abstract class, the implementation of this method
987       * is left to subclasses.
988       *
989       * @param index the index of the accessible child to check for selection.
990       * @return false.
991       */
992      public boolean isAccessibleChildSelected(int index)
993      {
994        return false;
995      }
996    
997      /**
998       * Returns true if this component is currently enabled.
999       * <br />
1000       * <br />
1001       * As this abstract component has no properties related to
1002       * its enabled or disabled state, the implementation of this
1003       * method is left to subclasses.
1004       *
1005       * @return false.
1006       * @see #setEnabled(boolean)
1007       */
1008      public boolean isEnabled()
1009      {
1010        return false;
1011      }
1012    
1013      /**
1014       * Returns true if this component is included in the traversal
1015       * of the current focus from one component to the other.
1016       * <br />
1017       * <br />
1018       * As this abstract component has no properties related to
1019       * its ability to accept the focus, the implementation of this
1020       * method is left to subclasses.
1021       *
1022       * @return false.
1023       */
1024      public boolean isFocusTraversable()
1025      {
1026        return false;
1027      }
1028    
1029      /**
1030       * Returns true if the component is being shown on screen.
1031       * A component is determined to be shown if it is visible,
1032       * and each parent component is also visible.  Please note
1033       * that, even when a component is showing, it may still be
1034       * obscured by other components in front.  This method only
1035       * determines if the component is being drawn on the screen.
1036       * <br />
1037       * <br />
1038       * As this abstract component and its parent have no properties
1039       * relating to visibility, the implementation of this method is
1040       * left to subclasses.
1041       *
1042       * @return false.
1043       * @see #isVisible()
1044       */
1045      public boolean isShowing()
1046      {
1047        return false;
1048      }
1049    
1050      /**
1051       * Returns true if the component is visible.  A component may
1052       * be visible but not drawn on the screen if one of its parent
1053       * components is not visible.  To determine if the component is
1054       * actually drawn on screen, <code>isShowing()</code> should be
1055       * used.
1056       * <br />
1057       * <br />
1058       * As this abstract component has no properties relating to its
1059       * visibility, the implementation of this method is left to subclasses.
1060       *
1061       * @return false.
1062       * @see #isShowing()
1063       * @see #setVisible(boolean)
1064       */
1065      public boolean isVisible()
1066      {
1067        return false;
1068      }
1069    
1070      /**
1071       * Removes the accessible child specified by the supplied index from
1072       * the list of currently selected children.  If the child specified
1073       * is not selected, nothing happens.
1074       * <br />
1075       * <br />
1076       * As the existence of children can not be determined from
1077       * this abstract class, the implementation of this method
1078       * is left to subclasses.
1079       *
1080       * @param index the index of the <code>Accessible</code> child.
1081       */
1082      public void removeAccessibleSelection(int index)
1083      {
1084        /* Subclasses with children should implement this */
1085      }
1086    
1087      /**
1088       * Removes the specified focus listener from the list of registered
1089       * focus listeners for this component.
1090       *
1091       * @param listener the listener to remove.
1092       */
1093      public void removeFocusListener(FocusListener listener)
1094      {
1095        /* Remove the focus listener from the chain */
1096        focusListener = AWTEventMulticaster.remove(focusListener, listener);
1097      }
1098    
1099      /**
1100       * Requests that this component gains focus.  This depends on the
1101       * component being focus traversable.
1102       * <br />
1103       * <br />
1104       * As this abstract component has no properties relating to its
1105       * focus traversability, or access to a peer with request focusing
1106       * abilities, the implementation of this method is left to subclasses.
1107       */
1108      public void requestFocus()
1109      {
1110        /* Ignored */
1111      }
1112    
1113      /**
1114       * Selects all <code>Accessible</code> children of this component which
1115       * it is possible to select.  The component needs to support multiple
1116       * selections.
1117       * <br />
1118       * <br />
1119       * This abstract component provides a simplistic implementation of this
1120       * method, which ignores the ability of the component to support multiple
1121       * selections and simply uses <code>addAccessibleSelection</code> to
1122       * add each <code>Accessible</code> child to the selection.  The last
1123       * <code>Accessible</code> component is thus selected for components
1124       * which don't support multiple selections.  Concrete implementations should
1125       * override this with a more appopriate and efficient implementation, which
1126       * properly takes into account the ability of the component to support multiple
1127       * selections.
1128       */
1129      public void selectAllAccessibleSelection()
1130      {
1131        /* Simply call addAccessibleSelection() on all accessible children */
1132        for (int a = 0; a < getAccessibleChildrenCount(); ++a)
1133          {
1134            addAccessibleSelection(a);
1135          }
1136      }
1137    
1138      /**
1139       * Sets the background color of the component to that specified.
1140       * Unspecified behaviour occurs when null is given as the new
1141       * background color.
1142       * <br />
1143       * <br />
1144       * This abstract class knows nothing about how the component
1145       * is drawn on screen, so this method simply ignores the supplied
1146       * color and continues to use the default system color.  
1147       * Concrete subclasses which handle the drawing of an onscreen
1148       * menu component should override this method and provide
1149       * the appropriate information.
1150       *
1151       * @param color the new color to use for the background.
1152       * @see getBackground()
1153       */
1154      public void setBackground(Color color)
1155      {
1156        /* Ignored */
1157      }
1158    
1159      /**
1160       * Sets the height and width of the component, and its position
1161       * relative to this component's parent, to the values specified
1162       * by the supplied rectangle.  Unspecified behaviour occurs when
1163       * null is given as the new bounds.
1164       * <br />
1165       * <br />
1166       * This abstract class knows nothing about how the component
1167       * is drawn on screen, so this method simply ignores the new
1168       * rectangle and continues to return null from <code>getBounds()</code>.
1169       * Concrete subclasses which handle the drawing of an onscreen
1170       * menu component should override this method and provide
1171       * the appropriate information.
1172       *
1173       * @param rectangle a rectangle which specifies the new bounds of
1174       *        the component.
1175       * @see #getBounds()
1176       */
1177      public void setBounds(Rectangle rectangle)
1178      {
1179        /* Ignored */
1180      }
1181    
1182      /**
1183       * Sets the <code>Cursor</code> used when the pointer is positioned over the
1184       * component.  Unspecified behaviour occurs when null is given as the new
1185       * cursor.
1186       * <br />
1187       * <br />
1188       * This abstract class knows nothing about how the component
1189       * is drawn on screen, so this method simply ignores the new cursor
1190       * and continues to return the default system cursor.  Concrete
1191       * subclasses which handle the drawing of an onscreen menu component
1192       * may override this method and provide the appropriate information.
1193       *
1194       * @param cursor the new cursor to use.
1195       * @see #getCursor()
1196       */
1197      public void setCursor(Cursor cursor)
1198      {
1199        /* Ignored */
1200      }
1201    
1202      /**
1203       * Sets the enabled/disabled state of this component.
1204       * <br />
1205       * <br />
1206       * As this abstract component has no properties related to
1207       * its enabled or disabled state, the implementation of this
1208       * method is left to subclasses.
1209       *
1210       * @param enabled true if the component should be enabled,
1211       *        false otherwise.
1212       * @see #getEnabled()
1213       */
1214      public void setEnabled(boolean enabled)
1215      {
1216        /* Ignored */
1217      }
1218    
1219      /**
1220       * Sets the <code>Font</code> used for text created by this component.
1221       * Unspecified behaviour occurs when null is given as the new
1222       * font.
1223       *
1224       * @param font the new font to use for text.
1225       * @see #getFont()
1226       */
1227      public void setFont(Font font)
1228      {
1229        /* Call the method of the enclosing component */
1230        MenuComponent.this.setFont(font);
1231      }
1232    
1233      /**
1234       * Sets the foreground color of the component to that specified.
1235       * Unspecified behaviour occurs when null is given as the new
1236       * background color.
1237       * <br />
1238       * <br />
1239       * This abstract class knows nothing about how the component
1240       * is drawn on screen, so this method simply ignores the supplied
1241       * color and continues to return the default system text color used
1242       * for rendering menus.
1243       * Concrete subclasses which handle the drawing of an onscreen
1244       * menu component should override this method and provide
1245       * the appropriate information.
1246       *
1247       * @param color the new foreground color.
1248       * @see #getForeground()
1249       */
1250      public void setForeground(Color color)
1251      {
1252        /* Ignored */
1253      }
1254    
1255      /**
1256       * Sets the location of the component, with co-ordinates
1257       * relative to the parent component and using the co-ordinate
1258       * space of the screen.  Thus, the point (0,0) is the upper
1259       * left corner of the parent component.
1260       * <br />
1261       * <br />
1262       * Please note that this method depends on a correctly implemented
1263       * version of the <code>getBounds()</code> method.  Subclasses
1264       * must provide the bounding rectangle via <code>getBounds()</code>
1265       * in order for this method to work.  
1266       *
1267       * @param point the location of the component, relative to its parent.
1268       * @see #getLocation()
1269       */
1270      public void setLocation(Point point)
1271      {
1272        getBounds().setLocation(point);
1273      }
1274    
1275      /**
1276       * Sets the size of the component.
1277       * <br />
1278       * <br />
1279       * Please note that this method depends on a correctly implemented
1280       * version of the <code>getBounds()</code> method.  Subclasses
1281       * must provide the bounding rectangle via <code>getBounds()</code>
1282       * in order for this method to work.  
1283       *
1284       * @param size the new size of the component.
1285       * @see #getSize()
1286       */
1287      public void setSize(Dimension size)
1288      {
1289        getBounds().setSize(size);
1290      }
1291    
1292      /**
1293       * Sets the visibility state of the component.  A component may
1294       * be visible but not drawn on the screen if one of its parent
1295       * components is not visible.  To determine if the component is
1296       * actually drawn on screen, <code>isShowing()</code> should be
1297       * used.
1298       * <br />
1299       * <br />
1300       * As this abstract component has no properties relating to its
1301       * visibility, the implementation of this method is left to subclasses.
1302       *
1303       * @param visibility the new visibility of the component -- true if
1304       *        the component is visible, false if not.
1305       * @see #isShowing()
1306       * @see #isVisible()
1307       */
1308      public void setVisible(boolean visibility)
1309      {
1310        /* Ignored */
1311      }
1312    
1313    } /* class AccessibleAWTMenuComponent */
1314              
1315    
1316  } // class Component  } // class MenuComponent

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26