[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath: Fixes for MenuBar
Kaffe CVS
cvs-commits at kaffe.org
Sun Sep 12 09:56:54 PDT 2004
PatchSet 5162
Date: 2004/09/12 16:53:03
Author: dalibor
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: Fixes for MenuBar
2004-09-12 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/awt/MenuComponent.java,
libraries/javalib/java/awt/Component.java,
libraries/javalib/java/awt/MenuBar.java,
libraries/javalib/java/awt/MenuComponent.java:
Resynced with GNU Classpath.
2004-09-11 Andrew John Hughes <gnu_andrew at member.fsf.org>
* java/awt/MenuComponent.java
(newEventsOnly): added additional serialization
comment
2004-09-11 Andrew John Hughes <gnu_andrew at member.fsf.org>
* java/awt/Component.java
(translateEvent): made static with package access
rather than private
* java/awt/MenuBar.java
Added documentation
(getAccessibleContext()): implemented
(AccessibleAWTMenuBar): new class
(AccessibleAWTMenuBar()): new constructor
(getAccessibleRole()): implemented
* java/awt/MenuComponent.java
(accessibleContext, newEventsOnly, nameExplicitlySet,
focusHandler): new variables
(setName(String)): adding setting of nameExplicitlySet
(dispatchEventImpl(java.awt.AWTEvent)): converts 1.1 events
to 1.0
(processEvent): added focus handling for accessible component
(getAccessibleContext()): implemented
(AccessibleAWTMenuComponent): new class
(AccessibleAWTMenuComponent()): new constructor
(addAccessibleSelection(int)): stub for subclasses
(addFocusListener(java.awt.event.FocusListener)): implemented
(clearAccessibleSelection()): stub for subclasses
(contains(java.awt.Point)): implemented against getBounds()
(getAccessibleAt(java.awt.Point)): stub for subclasses
(getAccessibleChild(int)): stub for subclasses
(getAccessibleChildrenCount()): stub for subclasses
(getAccessibleComponent()): implemented
(getAccessibleDescription()): implemented
(getAccessibleIndexInParent()): implemented
(getAccessibleName()): implemented
(getAccessibleParent()): implemented
(getAccessibleRole()): implemented
(getAccessibleSelection()): implemented
(getAccessibleSelection(int)): stub for subclasses
(getAccessibleSelectionCount()): stub for subclasses
(getAccessibleStateSet()): implemented
(getBackground()): implemented
(getBounds()): stub for subclasses
(getCursor()): implemented
(getFont()): implemented
(getFontMetrics(java.awt.Font)): implemented
(getForeground()): implemented
(getLocale()): implemented
(getLocation()): implemented against getBounds()
(getLocationOnScreen()): stub for subclasses
(getSize()): implemented against getBounds()
(isAccessibleChildSelected(int)): stub for subclasses
(isEnabled()): stub for subclasses
(isFocusTraversable()): stub for subclasses
(isShowing()): stub for subclasses
(isVisible()): stub for subclasses
(removeAccessibleSelection(int)): stub for subclasses
(removeFocusListener(java.awt.event.FocusListener)): implemented
(selectAllAccessibleSelection()): implemented against addAccessibleSelection(int)
(setBackground(java.awt.Color)): stub for subclasses
(setBounds(java.awt.Rectangle)): stub for subclasses
(setCursor(java.awt.Cursor)): stub for subclasses
(setEnabled(boolean)): stub for subclasses
(setFont(java.awt.Font)): implemented
(setForeground(java.awt.Color)): stub for subclasses
(setLocation(java.awt.Point)): implemented against setBounds()
(setSize(java.awt.Dimension)): implemented against setBounds()
(setVisible(boolean)): stub for subclasses
Members:
ChangeLog:1.2717->1.2718
libraries/javalib/java/awt/Component.java:1.36->1.37
libraries/javalib/java/awt/MenuBar.java:1.7->1.8
libraries/javalib/java/awt/MenuComponent.java:1.11->1.12
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2717 kaffe/ChangeLog:1.2718
--- kaffe/ChangeLog:1.2717 Sun Sep 12 15:10:51 2004
+++ kaffe/ChangeLog Sun Sep 12 16:53:03 2004
@@ -1,5 +1,85 @@
2004-09-12 Dalibor Topic <robilad at kaffe.org>
+ * libraries/javalib/java/awt/MenuComponent.java,
+ libraries/javalib/java/awt/Component.java,
+ libraries/javalib/java/awt/MenuBar.java,
+ libraries/javalib/java/awt/MenuComponent.java:
+ Resynced with GNU Classpath.
+
+ 2004-09-11 Andrew John Hughes <gnu_andrew at member.fsf.org>
+
+ * java/awt/MenuComponent.java
+ (newEventsOnly): added additional serialization
+ comment
+
+ 2004-09-11 Andrew John Hughes <gnu_andrew at member.fsf.org>
+
+ * java/awt/Component.java
+ (translateEvent): made static with package access
+ rather than private
+ * java/awt/MenuBar.java
+ Added documentation
+ (getAccessibleContext()): implemented
+ (AccessibleAWTMenuBar): new class
+ (AccessibleAWTMenuBar()): new constructor
+ (getAccessibleRole()): implemented
+ * java/awt/MenuComponent.java
+ (accessibleContext, newEventsOnly, nameExplicitlySet,
+ focusHandler): new variables
+ (setName(String)): adding setting of nameExplicitlySet
+ (dispatchEventImpl(java.awt.AWTEvent)): converts 1.1 events
+ to 1.0
+ (processEvent): added focus handling for accessible component
+ (getAccessibleContext()): implemented
+ (AccessibleAWTMenuComponent): new class
+ (AccessibleAWTMenuComponent()): new constructor
+ (addAccessibleSelection(int)): stub for subclasses
+ (addFocusListener(java.awt.event.FocusListener)): implemented
+ (clearAccessibleSelection()): stub for subclasses
+ (contains(java.awt.Point)): implemented against getBounds()
+ (getAccessibleAt(java.awt.Point)): stub for subclasses
+ (getAccessibleChild(int)): stub for subclasses
+ (getAccessibleChildrenCount()): stub for subclasses
+ (getAccessibleComponent()): implemented
+ (getAccessibleDescription()): implemented
+ (getAccessibleIndexInParent()): implemented
+ (getAccessibleName()): implemented
+ (getAccessibleParent()): implemented
+ (getAccessibleRole()): implemented
+ (getAccessibleSelection()): implemented
+ (getAccessibleSelection(int)): stub for subclasses
+ (getAccessibleSelectionCount()): stub for subclasses
+ (getAccessibleStateSet()): implemented
+ (getBackground()): implemented
+ (getBounds()): stub for subclasses
+ (getCursor()): implemented
+ (getFont()): implemented
+ (getFontMetrics(java.awt.Font)): implemented
+ (getForeground()): implemented
+ (getLocale()): implemented
+ (getLocation()): implemented against getBounds()
+ (getLocationOnScreen()): stub for subclasses
+ (getSize()): implemented against getBounds()
+ (isAccessibleChildSelected(int)): stub for subclasses
+ (isEnabled()): stub for subclasses
+ (isFocusTraversable()): stub for subclasses
+ (isShowing()): stub for subclasses
+ (isVisible()): stub for subclasses
+ (removeAccessibleSelection(int)): stub for subclasses
+ (removeFocusListener(java.awt.event.FocusListener)): implemented
+ (selectAllAccessibleSelection()): implemented against addAccessibleSelection(int)
+ (setBackground(java.awt.Color)): stub for subclasses
+ (setBounds(java.awt.Rectangle)): stub for subclasses
+ (setCursor(java.awt.Cursor)): stub for subclasses
+ (setEnabled(boolean)): stub for subclasses
+ (setFont(java.awt.Font)): implemented
+ (setForeground(java.awt.Color)): stub for subclasses
+ (setLocation(java.awt.Point)): implemented against setBounds()
+ (setSize(java.awt.Dimension)): implemented against setBounds()
+ (setVisible(boolean)): stub for subclasses
+
+2004-09-12 Dalibor Topic <robilad at kaffe.org>
+
* libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c,
libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics.java,
libraries/javalib/gnu/java/awt/peer/gtk/GdkGraphics2D.java,
Index: kaffe/libraries/javalib/java/awt/Component.java
diff -u kaffe/libraries/javalib/java/awt/Component.java:1.36 kaffe/libraries/javalib/java/awt/Component.java:1.37
--- kaffe/libraries/javalib/java/awt/Component.java:1.36 Sun Sep 12 15:10:58 2004
+++ kaffe/libraries/javalib/java/awt/Component.java Sun Sep 12 16:53:07 2004
@@ -4505,7 +4505,7 @@
*
* @return an AWT 1.0 event representing e
*/
- private Event translateEvent (AWTEvent e)
+ static Event translateEvent (AWTEvent e)
{
Component target = (Component) e.getSource ();
Event translated = null;
Index: kaffe/libraries/javalib/java/awt/MenuBar.java
diff -u kaffe/libraries/javalib/java/awt/MenuBar.java:1.7 kaffe/libraries/javalib/java/awt/MenuBar.java:1.8
--- kaffe/libraries/javalib/java/awt/MenuBar.java:1.7 Thu Jul 22 19:37:01 2004
+++ kaffe/libraries/javalib/java/awt/MenuBar.java Sun Sep 12 16:53:07 2004
@@ -45,14 +45,19 @@
import java.util.Enumeration;
import java.util.Vector;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
/**
* This class implements a menu bar in the AWT system.
*
* @author Aaron M. Renn (arenn at urbanophile.com)
* @author Tom Tromey <tromey at redhat.com>
+ * @author Andrew John Hughes <gnu_andrew at member.fsf.org>
*/
public class MenuBar extends MenuComponent
- implements MenuContainer, Serializable
+ implements MenuContainer, Serializable, Accessible
{
/*
@@ -78,6 +83,14 @@
*/
private Vector menus = new Vector();
+ /**
+ * The accessible context for this component.
+ *
+ * @see #getAccessibleContext()
+ * @serial ignored.
+ */
+ private transient AccessibleContext accessibleContext;
+
/*************************************************************************/
/*
@@ -352,5 +365,57 @@
while ((it = getShortcutMenuItem (shortcut)) != null)
it.deleteShortcut ();
}
+
+/**
+ * Gets the AccessibleContext associated with this <code>MenuBar</code>.
+ * The context is created, if necessary.
+ *
+ * @return the associated context
+ */
+public AccessibleContext getAccessibleContext()
+{
+ /* Create the context if this is the first request */
+ if (accessibleContext == null)
+ {
+ /* Create the context */
+ accessibleContext = new AccessibleAWTMenuBar();
+ }
+ return accessibleContext;
+}
+
+/**
+ * This class provides accessibility support for AWT menu bars.
+ *
+ * @author Andrew John Hughes <gnu_andrew at member.fsf.org>
+ */
+protected class AccessibleAWTMenuBar
+ extends AccessibleAWTMenuComponent
+{
+
+ /**
+ * Compatible with JDK 1.4.2 revision 5
+ */
+ private static final long serialVersionUID = -8577604491830083815L;
+
+ /**
+ * This is the default constructor, which simply calls the default
+ * constructor of the superclass.
+ */
+ protected AccessibleAWTMenuBar()
+ {
+ super();
+ }
+
+ /**
+ * Returns the accessible role relating to the menu bar.
+ *
+ * @return <code>AccessibleRole.MENU_BAR</code>.
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.MENU_BAR;
+ }
+
+} // class AccessibleAWTMenuBar
} // class MenuBar
Index: kaffe/libraries/javalib/java/awt/MenuComponent.java
diff -u kaffe/libraries/javalib/java/awt/MenuComponent.java:1.11 kaffe/libraries/javalib/java/awt/MenuComponent.java:1.12
--- kaffe/libraries/javalib/java/awt/MenuComponent.java:1.11 Thu Jul 22 19:37:01 2004
+++ kaffe/libraries/javalib/java/awt/MenuComponent.java Sun Sep 12 16:53:07 2004
@@ -38,15 +38,23 @@
package java.awt;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.awt.peer.MenuComponentPeer;
import java.io.Serializable;
-
-// FIXME: Java 1.0 event model unimplemented
+import java.util.Locale;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleStateSet;
/**
- * This is the superclass of all non-menu AWT widgets.
+ * This is the superclass of all menu AWT widgets.
*
* @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Andrew John Hughes <gnu_andrew at member.fsf.org>
*/
public abstract class MenuComponent implements Serializable
{
@@ -59,31 +67,101 @@
private static final long serialVersionUID = -4536902356223894379L;
/*************************************************************************/
-
+
/*
* Instance Variables
*/
- // FIXME: missing serialized fields `nameExplicitlySet',
- // `newEventsOnly', and `accessibleContext'.
-
-// The font for this component
-private Font font;
-
-// The name of the component
-private String name;
-
-// 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;
+/**
+ * The font for this component.
+ *
+ * @see #getFont()
+ * @see #setFont(java.awt.Font)
+ * @serial the component's font.
+ */
+ private Font font;
-// The toolkit for this object
-private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
+ /**
+ * The name of the component.
+ *
+ * @see #getName()
+ * @see #setName(String)
+ * @serial the component's name.
+ */
+ private String name;
+
+ /**
+ * The parent of this component.
+ *
+ * @see #getParent()
+ * @see #setParent(java.awt.MenuContainer)
+ * @serial ignored.
+ */
+ transient MenuContainer parent;
+
+ /**
+ * The native peer for this component.
+ *
+ * @see #getPeer()
+ * @see #setPeer(java.awt.peer.MenuComponentPeer)
+ * @serial ignored.
+ */
+ transient MenuComponentPeer peer;
+
+ /**
+ * The synchronization locking object for this component.
+ *
+ * @serial ignored.
+ */
+ private transient Object tree_lock = this;
+
+ /**
+ * The toolkit for this object.
+ *
+ * @see #getToolkit()
+ * @serial ignored.
+ */
+ private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
+
+ /**
+ * The accessible context for this component.
+ *
+ * @see #getAccessibleContext()
+ * @serial the accessibility information for this component.
+ */
+ private AccessibleContext accessibleContext;
+
+ /**
+ * Was the name of the component set? This value defaults
+ * to false and becomes true after a call to <code>setName()</code>.
+ * Please note that this does not guarantee that name will then
+ * be non-null, as this may be the value passed to <code>setName()</code>.
+ *
+ * @see #setName(String)
+ * @serial true if the name value has been explicitly set by calling
+ * <code>setName()</code>.
+ */
+ private boolean nameExplicitlySet;
+
+ /**
+ * Does this component handle new events? Events will be handled
+ * by this component if this is true. Otherwise, they will be forwarded
+ * up the component hierarchy. This implementation does not use this
+ * variable; it is merely provided for serialization compatability.
+ *
+ * @see #dispatchEvent(AWTEvent)
+ * @serial true if events are to be processed locally. Unused.
+ */
+ private boolean newEventsOnly;
+
+ /**
+ * The focus listener chain handler which deals with focus events for
+ * the accessible context of this component.
+ *
+ * @see AccessibleAWTMenuComponent#addFocusListener(java.awt.event.FocusListener)
+ * @serial ignored.
+ */
+ private transient FocusListener focusListener;
/*************************************************************************/
@@ -157,6 +235,7 @@
setName(String name)
{
this.name = name;
+ nameExplicitlySet = true;
}
/*************************************************************************/
@@ -260,13 +339,14 @@
* AWT 1.0 event dispatcher.
*
* @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
+ * @return true if the event was dispatched, false otherwise.
*/
public boolean
postEvent(Event event)
{
- return(false);
+ // This is overridden by subclasses that support events.
+ return false;
}
-
/*************************************************************************/
/**
@@ -274,17 +354,35 @@
*
* @param event The event to dispatch
*/
-public final void
-dispatchEvent(AWTEvent event)
+public final void dispatchEvent(AWTEvent event)
{
// See comment in Component.dispatchEvent().
dispatchEventImpl(event);
}
-void
-dispatchEventImpl(AWTEvent e)
+
+/**
+ * Implementation of dispatchEvent. Allows trusted package classes
+ * to dispatch additional events first. This implementation first
+ * translates <code>event</code> to an AWT 1.0 event and sends the
+ * result to {@link #postEvent}. The event is then
+ * passed on to {@link #processEvent} for local processing.
+ *
+ * @param event the event to dispatch.
+ */
+void dispatchEventImpl(AWTEvent event)
{
+ Event oldStyleEvent;
+
// This is overridden by subclasses that support events.
+ /* Convert AWT 1.1 event to AWT 1.0 event */
+ oldStyleEvent = Component.translateEvent(event);
+ if (oldStyleEvent != null)
+ {
+ postEvent(oldStyleEvent);
+ }
+ /* Do local processing */
+ processEvent(event);
}
/*************************************************************************/
@@ -298,6 +396,25 @@
protected void
processEvent(AWTEvent event)
{
+ /*
+ Pass a focus event to the focus listener for
+ the accessibility context.
+ */
+ if (event instanceof FocusEvent)
+ {
+ if (focusListener != null)
+ {
+ switch (event.id)
+ {
+ case FocusEvent.FOCUS_GAINED:
+ focusListener.focusGained((FocusEvent) event);
+ break;
+ case FocusEvent.FOCUS_LOST:
+ focusListener.focusLost((FocusEvent) event);
+ break;
+ }
+ }
+ }
}
/*************************************************************************/
@@ -316,15 +433,884 @@
/*************************************************************************/
/**
- * Returns a debugging string for this component
- */
+ * Returns a debugging string for this component
+ */
protected String
paramString()
{
return "name=" + getName();
}
-// Accessibility API not yet implemented.
-// public AccessibleContext getAccessibleContext()
+/**
+ * Gets the AccessibleContext associated with this <code>MenuComponent</code>.
+ * As an abstract class, we return null. Concrete subclasses should return
+ * their implementation of the accessibility context.
+ *
+ * @return null.
+ */
+
+public AccessibleContext getAccessibleContext()
+{
+ return null;
+}
+
+/**
+ * This class provides a base for the accessibility support of menu
+ * components.
+ *
+ * @author Andrew John Hughes <gnu_andrew at member.fsf.org>
+ */
+protected abstract class AccessibleAWTMenuComponent
+ extends AccessibleContext
+ implements Serializable, AccessibleComponent, AccessibleSelection
+{
+
+ /**
+ * Compatible with JDK 1.4.2 revision 5
+ */
+ private static final long serialVersionUID = -4269533416223798698L;
+
+ /**
+ * This is the default constructor. It should be called by
+ * concrete subclasses to ensure necessary groundwork is completed.
+ */
+ protected AccessibleAWTMenuComponent()
+ {
+ }
+
+ /**
+ * Replaces or supplements the component's selection with the
+ * <code>Accessible</code> child at the supplied index. If
+ * the component supports multiple selection, the child is
+ * added to the current selection. Otherwise, the current
+ * selection becomes the specified child. If the child is
+ * already selected, nothing happens.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the specified child within a
+ * zero-based list of the component's children.
+ */
+ public void addAccessibleSelection(int index)
+ {
+ /* Subclasses with children should implement this */
+ }
+
+ /**
+ * Registers the specified focus listener to receive
+ * focus events from this component.
+ *
+ * @param listener the new focus listener.
+ */
+ public void addFocusListener(FocusListener listener)
+ {
+ /*
+ * Chain the new focus listener to the existing chain
+ * of focus listeners. Each new focus listener is
+ * coupled via multicasting to the existing chain.
+ */
+ focusListener = AWTEventMulticaster.add(focusListener, listener);
+ }
+
+ /**
+ * Clears the component's current selection. Following
+ * the calling of this method, no children of the component
+ * will be selected.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ */
+ public void clearAccessibleSelection()
+ {
+ }
+
+ /**
+ * Returns true if the specified point lies within the
+ * component. The supplied co-ordinates are assumed to
+ * be relative to the co-ordinate system of the component
+ * itself. Thus, the point (0,0) is the upper left corner
+ * of this component.
+ * <br />
+ * <br />
+ * Please note that this method depends on a correctly implemented
+ * version of the <code>getBounds()</code> method. Subclasses
+ * must provide the bounding rectangle via <code>getBounds()</code>
+ * in order for this method to work.
+ *
+ * @param point the point to check against this component.
+ * @return true if the point is within this component.
+ * @see #getBounds()
+ */
+ public boolean contains(Point point)
+ {
+ /*
+ We can simply return the result of a
+ test for containment in the bounding rectangle
+ */
+ return getBounds().contains(point);
+ }
+
+ /**
+ * Returns the <code>Accessible</code> child of this component present
+ * at the specified point. The supplied co-ordinates are
+ * assumed to be relative to the co-ordinate system of this
+ * component (the parent of any returned accessible). Thus,
+ * the point (0,0) is the upper left corner of this menu
+ * component.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param point the point at which the returned accessible
+ * is located.
+ * @return null.
+ */
+ public Accessible getAccessibleAt(Point point)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the <code>Accessible</code> child at the supplied
+ * index within the list of children of this component.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the <code>Accessible</code> child
+ * to retrieve.
+ * @return null.
+ */
+ public Accessible getAccessibleChild(int index)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the number of children of this component which
+ * implement the <code>Accessible</code> interface. If
+ * all children of this component are accessible, then
+ * the returned value will be the same as the number of
+ * children.
+ * <br />
+ * <br />
+ *
+ * @return 0.
+ */
+ public int getAccessibleChildrenCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Retrieves the <code>AccessibleComponent</code> associated
+ * with this accessible context and its component. As the
+ * context itself implements <code>AccessibleComponent</code>,
+ * this is the return value.
+ *
+ * @return the context itself.
+ */
+ public AccessibleComponent getAccessibleComponent()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the accessible name for this menu component. This
+ * is the name given to the component, which may be null if
+ * not set using <code>setName()</code>.
+ * <br />
+ * <br />
+ * The name is not the most appropriate description of this
+ * object. Subclasses should preferably provide a more
+ * accurate description. For example, a File menu could
+ * have the description `Lists commands related to the
+ * file system'.
+ *
+ * @return a description of the component. Currently,
+ * this is just the contents of the name property.
+ * @see MenuComponent#setName(String)
+ */
+ public String getAccessibleDescription()
+ {
+ return MenuComponent.this.getName();
+ }
+
+ /**
+ * Retrieves the index of this component within its parent.
+ * If no parent exists, -1 is returned.
+ *
+ * @return -1 as the parent, a <code>MenuContainer</code>
+ * is not <code>Accessible</code>.
+ */
+ public int getAccessibleIndexInParent()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the accessible name of this component. This
+ * is the name given to the component, which may be null if
+ * not set using <code>setName()</code>.
+ * <br />
+ * <br />
+ * The name property is not the most suitable string to return
+ * for this method. The string should be localized, and
+ * relevant to the operation of the component. For example,
+ * it could be the text of a menu item. However, this can
+ * not be used at this level of abstraction, so it is the
+ * responsibility of subclasses to provide a more appropriate
+ * name.
+ *
+ * @return a localized name for this component. Currently, this
+ * is just the contents of the name property.
+ * @see MenuComponent#setName(String)
+ */
+ public String getAccessibleName()
+ {
+ return MenuComponent.this.getName();
+ }
+
+ /**
+ * Returns the <code>Accessible</code> parent of this component.
+ * As the parent of a <code>MenuComponent</code> is a
+ * <code>MenuContainer</code>, which doesn't implement
+ * <code>Accessible</code>, this method returns null.
+ *
+ * @return null.
+ */
+ public Accessible getAccessibleParent()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the accessible role of this component.
+ * <br />
+ * <br />
+ * The abstract implementation of this method returns
+ * <code>AccessibleRole.AWT_COMPONENT</code>,
+ * as the abstract component has no specific role. This
+ * method should be overridden by concrete subclasses, so
+ * as to return an appropriate role for the component.
+ *
+ * @return <code>AccessibleRole.AWT_COMPONENT</code>.
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.AWT_COMPONENT;
+ }
+
+ /**
+ * Retrieves the <code>AccessibleSelection</code> associated
+ * with this accessible context and its component. As the
+ * context itself implements <code>AccessibleSelection</code>,
+ * this is the return value.
+ *
+ * @return the context itself.
+ */
+ public AccessibleSelection getAccessibleSelection()
+ {
+ return this;
+ }
+
+ /**
+ * Retrieves the <code>Accessible</code> selected child
+ * at the specified index. If there are no selected children
+ * or the index is outside the range of selected children,
+ * null is returned. Please note that the index refers
+ * to the index of the child in the list of <strong>selected
+ * children</strong>, and not the index of the child in
+ * the list of all <code>Accessible</code> children.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the selected <code>Accessible</code>
+ * child.
+ */
+ public Accessible getAccessibleSelection(int index)
+ {
+ return null;
+ }
+
+ /**
+ * Returns a count of the number of <code>Accessible</code>
+ * children of this component which are currently selected.
+ * If there are no children currently selected, 0 is returned.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @return 0.
+ */
+ public int getAccessibleSelectionCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Retrieves the current state of this component
+ * in an accessible form. For example, a given component
+ * may be visible, selected, disabled, etc.
+ * <br />
+ * <br />
+ * As this class tells us virtually nothing about the component,
+ * except for its name and font, no state information can be
+ * provided. This implementation thus returns an empty
+ * state set, and it is left to concrete subclasses to provide
+ * a more acceptable and relevant state set. Changes to these
+ * properties also need to be handled using
+ * <code>PropertyChangeListener</code>s.
+ *
+ * @return an empty <code>AccessibleStateSet</code>.
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ return new AccessibleStateSet();
+ }
+
+ /**
+ * Returns the background color of the component, or null
+ * if this property is unsupported.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns the
+ * default system background color used for rendering menus.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @return the default system background color for menus.
+ * @see #setBackground(java.awt.Color)
+ */
+ public Color getBackground()
+ {
+ return SystemColor.menu;
+ }
+
+ /**
+ * Returns a <code>Rectangle</code> which represents the
+ * bounds of this component. The returned rectangle has the
+ * height and width of the component's bounds, and is positioned
+ * at a location relative to this component's parent, the
+ * <code>MenuContainer</code>. null is returned if bounds
+ * are not supported by the component.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns null.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @return null.
+ * @see #setBounds(java.awt.Rectangle)
+ */
+ public Rectangle getBounds()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the <code>Cursor</code> displayed when the pointer
+ * is positioned over this component. Alternatively, null
+ * is returned if the component doesn't support the cursor
+ * property.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns the default
+ * system cursor. Concrete subclasses which handle the drawing
+ * of an onscreen menu component may override this method and provide
+ * the appropriate information.
+ *
+ * @return the default system cursor.
+ * @see #setCursor(java.awt.Cursor)
+ */
+ public Cursor getCursor()
+ {
+ return Cursor.getDefaultCursor();
+ }
+
+ /**
+ * Returns the <code>Font</code> used for text created by this component.
+ *
+ * @return the current font.
+ * @see #setFont(java.awt.Font)
+ */
+ public Font getFont()
+ {
+ return MenuComponent.this.getFont();
+ }
+
+ /**
+ * Retrieves information on the rendering and metrics of the supplied
+ * font. If font metrics are not supported by this component, null
+ * is returned.
+ * <br />
+ * <br />
+ * The abstract implementation of this method simply uses the toolkit
+ * to obtain the <code>FontMetrics</code>. Concrete subclasses may
+ * find it more efficient to invoke their peer class directly, if one
+ * is available.
+ *
+ * @param font the font about which to retrieve rendering and metric
+ * information.
+ * @return the metrics of the given font, as provided by the system
+ * toolkit.
+ * @throws NullPointerException if the supplied font was null.
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return MenuComponent.this.getToolkit().getFontMetrics(font);
+ }
+
+ /**
+ * Returns the foreground color of the component, or null
+ * if this property is unsupported.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
*** Patch too long, truncated ***
More information about the kaffe
mailing list