[gui] Implement missing Window methods and accessibility

Jerry Quinn jlquinn@optonline.net
Wed Dec 29 04:13:00 GMT 2004


2004-12-28  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/Window.java (AccessibleAWTWindow): Implement.
	(isActive, isFocused, getAccessibleContext): Implement.

Index: Window.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/Window.java,v
retrieving revision 1.32.12.15
diff -u -r1.32.12.15 Window.java
--- Window.java	9 Dec 2004 21:36:47 -0000	1.32.12.15
+++ Window.java	29 Dec 2004 03:46:37 -0000
@@ -56,6 +56,9 @@

  import javax.accessibility.Accessible;
  import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;

  /**
   * This class represents a top-level window with no decorations.
@@ -89,6 +92,22 @@
    private transient boolean shown;

    private transient Component windowFocusOwner;
+
+  protected class AccessibleAWTWindow extends AccessibleAWTContainer
+  {
+    public AccessibleRole getAccessibleRole()
+    {
+      return AccessibleRole.WINDOW;
+    }
+
+    public AccessibleStateSet getAccessibleState()
+    {
+      AccessibleStateSet states = super.getAccessibleStateSet();
+      if (isActive())
+        states.add(AccessibleState.ACTIVE);
+      return states;
+    }
+  }

    /**
     * This (package access) constructor is used by subclasses that want
@@ -672,8 +691,34 @@
  	  }
        }
    }
+
+  /**
+   * Identifies if this window is active.  The active window is a Frame or
+   * Dialog that has focus or owns the active window.
+   *
+   * @return true if active, else false.
+   * @since 1.4
+   */
+  public boolean isActive()
+  {
+    KeyboardFocusManager manager = 
KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+    return manager.getActiveWindow() == this;
+  }

    /**
+   * Identifies if this window is focused.  A window is focused if it is the
+   * focus owner or it contains the focus owner.
+   *
+   * @return true if focused, else false.
+   * @since 1.4
+   */
+  public boolean isFocused()
+  {
+    KeyboardFocusManager manager = 
KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+    return manager.getFocusedWindow() == this;
+  }
+
+  /**
     * Returns the child window that has focus if this window is active.
     * This method returns <code>null</code> if this window is not active
     * or no children have focus.
@@ -770,11 +815,21 @@
        applyResourceBundle(rb);
    }

+  /**
+   * Gets the AccessibleContext associated with this <code>List</code>.
+   * The context is created, if necessary.
+   *
+   * @return the associated context
+   */
    public AccessibleContext getAccessibleContext()
    {
-    // FIXME
-    //return null;
-    throw new Error ("Not implemented");
+    /* Create the context if this is the first request */
+    if (accessibleContext == null)
+      {
+        /* Create the context */
+        accessibleContext = new AccessibleAWTWindow();
+      }
+    return accessibleContext;
    }

    /**



More information about the Java-patches mailing list