This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gui] Add AccessibleAWTButton


2004-11-07 Jerry Quinn <jlquinn@optonline.net>

* java/awt/MenuItem.java (AccessibleAWTMenuItem): Implement.

Index: Button.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Button.java,v
retrieving revision 1.12.2.3
retrieving revision 1.12.2.4
diff -u -r1.12.2.3 -r1.12.2.4
--- Button.java	16 Oct 2004 15:55:18 -0000	1.12.2.3
+++ Button.java	7 Nov 2004 15:13:03 -0000	1.12.2.4
@@ -44,13 +44,21 @@
 import java.lang.reflect.Array;
 import java.util.EventListener;

+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRelation;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleValue;
+
 /**
   * This class provides a button widget for the AWT.
   *
   * @author Aaron M. Renn (arenn@urbanophile.com)
   * @author Tom Tromey <tromey@cygnus.com>
   */
-public class Button extends Component implements java.io.Serializable
+public class Button extends Component
+  implements java.io.Serializable, Accessible
 {

/*
@@ -85,6 +93,97 @@
* The number used to generate the name returned by getName.
*/
private static transient long next_button_number;
+
+ protected class AccessibleAWTButton extends AccessibleAWTComponent
+ implements AccessibleAction, AccessibleValue
+ {
+ protected AccessibleAWTButton() { }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionCount()
+ */
+ public int getAccessibleActionCount()
+ {
+ // Only 1 action possible
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionDescription(int)
+ */
+ public String getAccessibleActionDescription(int i)
+ {
+ if (i != 0)
+ return null;
+ return actionCommand;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#doAccessibleAction(int)
+ */
+ public boolean doAccessibleAction(int i)
+ {
+ if (i != 0)
+ return false;
+ processActionEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand));
+ return true;
+ }
+
+ public String getAccessibleName()
+ {
+ return label;
+ }
+
+ public AccessibleAction getAccessibleAction()
+ {
+ return this;
+ }
+
+ public AccessibleValue getAccessibleValue()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getCurrentAccessibleValue()
+ */
+ public Number getCurrentAccessibleValue()
+ {
+ // Docs say return 1 if selected, but buttons can't be selected, right?
+ return new Integer(0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#setCurrentAccessibleValue(java.lang.Number)
+ */
+ public boolean setCurrentAccessibleValue(Number number)
+ {
+ // Since there's no selection with buttons, we're ignoring this.
+ // TODO someone who knows shoulw check this.
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getMinimumAccessibleValue()
+ */
+ public Number getMinimumAccessibleValue()
+ {
+ return new Integer(0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getMaximumAccessibleValue()
+ */
+ public Number getMaximumAccessibleValue()
+ {
+ return new Integer(0);
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.PUSH_BUTTON;
+ }
+ }


/*************************************************************************/

@@ -314,6 +413,11 @@
     + getWidth () + "x" + getHeight () + ",label=" + getLabel ();
 }

+public AccessibleContext getAccessibleContext()
+{
+  return new AccessibleAWTButton();
+}
+
   /**
    * Generate a unique name for this button.
    *


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]