[java-atk-wrapper] Add the AtkUtil.invokeInSwing helper function to fix EDT safety



commit a0fc8d15c58f29fc4ead954dad4c85a864295f65
Author: Giuseppe <giuseppecapaldo93 gmail com>
Date:   Thu Jun 6 11:02:12 2019 +0200

    Add the AtkUtil.invokeInSwing helper function to fix EDT safety
    
    We have to avoid touching anything about Swing in the JAW thread. The
    AtkUtil.invokeInSwing helper uses SwingUtilities.invokeLater to just
    defer the work to EDT's idle time.

 jni/src/jawaction.c                                |   9 +-
 jni/src/jawcomponent.c                             |   9 +-
 jni/src/jaweditabletext.c                          |   9 +-
 jni/src/jawhypertext.c                             |   9 +-
 jni/src/jawimage.c                                 |  11 +-
 jni/src/jawselection.c                             |   7 +-
 jni/src/jawtable.c                                 |   8 +-
 jni/src/jawtablecell.c                             |   5 +-
 jni/src/jawtext.c                                  |   9 +-
 jni/src/jawvalue.c                                 |   9 +-
 wrapper/org/GNOME/Accessibility/AtkAction.java     |  44 ++--
 wrapper/org/GNOME/Accessibility/AtkComponent.java  | 159 ++++++------
 .../org/GNOME/Accessibility/AtkEditableText.java   | 107 ++++----
 wrapper/org/GNOME/Accessibility/AtkHyperlink.java  |  38 +--
 wrapper/org/GNOME/Accessibility/AtkHypertext.java  |  43 ++--
 wrapper/org/GNOME/Accessibility/AtkImage.java      |  53 ++--
 wrapper/org/GNOME/Accessibility/AtkSelection.java  |  51 ++--
 wrapper/org/GNOME/Accessibility/AtkTable.java      | 220 ++++++++---------
 wrapper/org/GNOME/Accessibility/AtkTableCell.java  | 115 +++++----
 wrapper/org/GNOME/Accessibility/AtkText.java       | 273 ++++++++++-----------
 wrapper/org/GNOME/Accessibility/AtkUtil.java       |  76 ++++++
 wrapper/org/GNOME/Accessibility/AtkValue.java      |  13 +-
 wrapper/org/GNOME/Accessibility/AtkWrapper.java.in | 125 +++++-----
 23 files changed, 736 insertions(+), 666 deletions(-)
---
diff --git a/jni/src/jawaction.c b/jni/src/jawaction.c
index ab3610c..adc66c3 100644
--- a/jni/src/jawaction.c
+++ b/jni/src/jawaction.c
@@ -61,11 +61,11 @@ jaw_action_data_init (jobject ac)
   JNIEnv *jniEnv = jaw_util_get_jni_env();
   jclass classAction = (*jniEnv)->FindClass(jniEnv,
                                             "org/GNOME/Accessibility/AtkAction");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv,
                                           classAction,
-                                          "<init>",
-                                          "(Ljavax/accessibility/AccessibleContext;)V");
-  jobject jatk_action = (*jniEnv)->NewObject(jniEnv, classAction, jmid, ac);
+                                          "createAtkAction",
+                                          
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkAction;");
+  jobject jatk_action = (*jniEnv)->CallStaticObjectMethod(jniEnv, classAction, jmid, ac);
   data->atk_action = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_action);
 
   return data;
@@ -340,4 +340,3 @@ jaw_action_get_keybinding (AtkAction *action, gint i)
                                                                  NULL);
   return data->action_keybinding;
 }
-
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index 8c7d54e..b156fde 100644
--- a/jni/src/jawcomponent.c
+++ b/jni/src/jawcomponent.c
@@ -76,12 +76,12 @@ jaw_component_data_init (jobject ac)
   JNIEnv *jniEnv = jaw_util_get_jni_env();
   jclass classComponent = (*jniEnv)->FindClass(jniEnv,
                                                "org/GNOME/Accessibility/AtkComponent");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv,
                                           classComponent,
-                                          "<init>",
-                                          "(Ljavax/accessibility/AccessibleContext;)V");
+                                          "createAtkComponent",
+                                          
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkComponent;");
 
-  jobject jatk_component = (*jniEnv)->NewObject(jniEnv, classComponent, jmid, ac);
+  jobject jatk_component = (*jniEnv)->CallStaticObjectMethod(jniEnv, classComponent, jmid, ac);
   data->atk_component = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_component);
 
   return data;
@@ -350,4 +350,3 @@ jaw_component_get_layer (AtkComponent *component)
 
   return (AtkLayer)jlayer;
 }
-
diff --git a/jni/src/jaweditabletext.c b/jni/src/jaweditabletext.c
index 3b351ba..2445ab4 100644
--- a/jni/src/jaweditabletext.c
+++ b/jni/src/jaweditabletext.c
@@ -70,11 +70,11 @@ jaw_editable_text_data_init (jobject ac)
   JNIEnv *jniEnv = jaw_util_get_jni_env();
   jclass classEditableText = (*jniEnv)->FindClass(jniEnv,
                                                   "org/GNOME/Accessibility/AtkEditableText");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv,
                                           classEditableText,
-                                          "<init>",
-                                          "(Ljavax/accessibility/AccessibleContext;)V");
-  jobject jatk_editable_text = (*jniEnv)->NewObject(jniEnv,
+                                          "createAtkEditableText",
+                                          
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkEditableText;");
+  jobject jatk_editable_text = (*jniEnv)->CallStaticObjectMethod(jniEnv,
                                                     classEditableText,
                                                     jmid,
                                                     ac);
@@ -290,4 +290,3 @@ jaw_editable_text_set_run_attributes(AtkEditableText *text,
 
   return FALSE;
 }
-
diff --git a/jni/src/jawhypertext.c b/jni/src/jawhypertext.c
index 9c35b97..18157b3 100644
--- a/jni/src/jawhypertext.c
+++ b/jni/src/jawhypertext.c
@@ -57,8 +57,8 @@ jaw_hypertext_data_init (jobject ac)
 
        JNIEnv *jniEnv = jaw_util_get_jni_env();
        jclass classHypertext = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkHypertext");
-       jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classHypertext, "<init>", 
"(Ljavax/accessibility/AccessibleContext;)V");
-       jobject jatk_hypertext = (*jniEnv)->NewObject(jniEnv, classHypertext, jmid, ac);
+       jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv, classHypertext, "createAtkHypertext", 
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkHypertext;");
+       jobject jatk_hypertext = (*jniEnv)->CallStaticObjectMethod(jniEnv, classHypertext, jmid, ac);
        data->atk_hypertext = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_hypertext);
 
        data->link_table = g_hash_table_new_full(NULL, NULL, NULL, link_destroy_notify);
@@ -119,7 +119,7 @@ jaw_hypertext_get_n_links (AtkHypertext *hypertext)
 
        jclass classAtkHypertext = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkHypertext");
        jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkHypertext, "get_n_links", "()I");
-       
+
        gint ret = (gint)(*jniEnv)->CallIntMethod(jniEnv, atk_hypertext, jmid);
        (*jniEnv)->DeleteGlobalRef(jniEnv, atk_hypertext);
        return ret;
@@ -138,9 +138,8 @@ jaw_hypertext_get_link_index (AtkHypertext *hypertext, gint char_index)
 
        jclass classAtkHypertext = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkHypertext");
        jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkHypertext, "get_link_index", "(I)I");
-       
+
        gint ret = (gint)(*jniEnv)->CallIntMethod(jniEnv, atk_hypertext, jmid, (jint)char_index);
        (*jniEnv)->DeleteGlobalRef(jniEnv, atk_hypertext);
        return ret;
 }
-
diff --git a/jni/src/jawimage.c b/jni/src/jawimage.c
index bf25dec..da9701c 100644
--- a/jni/src/jawimage.c
+++ b/jni/src/jawimage.c
@@ -53,8 +53,8 @@ jaw_image_data_init (jobject ac)
 
        JNIEnv *jniEnv = jaw_util_get_jni_env();
        jclass classImage = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkImage");
-       jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classImage, "<init>", 
"(Ljavax/accessibility/AccessibleContext;)V");
-       jobject jatk_image = (*jniEnv)->NewObject(jniEnv, classImage, jmid, ac);
+       jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv, classImage, "createAtkImage", 
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkImage;");
+       jobject jatk_image = (*jniEnv)->CallStaticObjectMethod(jniEnv, classImage, jmid, ac);
        data->atk_image = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_image);
 
        return data;
@@ -96,7 +96,7 @@ jaw_image_get_image_position (AtkImage *image,
        jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkImage, "get_image_position", 
"(I)Ljava/awt/Point;");
        jobject jpoint = (*jniEnv)->CallObjectMethod(jniEnv, atk_image, jmid, (jint)coord_type);
        (*jniEnv)->DeleteGlobalRef(jniEnv, atk_image);
-       
+
        if (jpoint == NULL) {
                (*x) = 0;
                (*y) = 0;
@@ -128,12 +128,12 @@ jaw_image_get_image_description (AtkImage *image)
        jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkImage, "get_image_description", 
"()Ljava/lang/String;");
        jstring jstr = (*jniEnv)->CallObjectMethod(jniEnv, atk_image, jmid);
        (*jniEnv)->DeleteGlobalRef(jniEnv, atk_image);
-       
+
        if (data->image_description != NULL) {
                (*jniEnv)->ReleaseStringUTFChars(jniEnv, data->jstrImageDescription, data->image_description);
                (*jniEnv)->DeleteGlobalRef(jniEnv, data->jstrImageDescription);
        }
-       
+
        data->jstrImageDescription = (*jniEnv)->NewGlobalRef(jniEnv, jstr);
        data->image_description = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv, data->jstrImageDescription, 
NULL);
 
@@ -171,4 +171,3 @@ jaw_image_get_image_size (AtkImage *image, gint *width, gint *height)
        (*width) = (gint)jwidth;
        (*height) = (gint)jheight;
 }
-
diff --git a/jni/src/jawselection.c b/jni/src/jawselection.c
index 95dae4e..76214f5 100644
--- a/jni/src/jawselection.c
+++ b/jni/src/jawselection.c
@@ -57,8 +57,8 @@ jaw_selection_data_init (jobject ac)
 
        JNIEnv *jniEnv = jaw_util_get_jni_env();
        jclass classSelection = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkSelection");
-       jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classSelection, "<init>", 
"(Ljavax/accessibility/AccessibleContext;)V");
-       jobject jatk_selection = (*jniEnv)->NewObject(jniEnv, classSelection, jmid, ac);
+       jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv, classSelection, "createAtkSelection", 
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkSelection;");
+       jobject jatk_selection = (*jniEnv)->CallStaticObjectMethod(jniEnv, classSelection, jmid, ac);
        data->atk_selection = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_selection);
 
        return data;
@@ -140,7 +140,7 @@ jaw_selection_ref_selection (AtkSelection *selection, gint i)
        if (!jchild) {
                return NULL;
        }
-       
+
        jclass classAccessible = (*jniEnv)->FindClass( jniEnv, "javax/accessibility/Accessible" );
        jmid = (*jniEnv)->GetMethodID( jniEnv, classAccessible, "getAccessibleContext", 
"()Ljavax/accessibility/AccessibleContext;" );
        jobject child_ac = (*jniEnv)->CallObjectMethod( jniEnv, jchild, jmid );
@@ -238,4 +238,3 @@ jaw_selection_select_all_selection (AtkSelection *selection)
                return FALSE;
        }
 }
-
diff --git a/jni/src/jawtable.c b/jni/src/jawtable.c
index 3b02382..8dd1479 100644
--- a/jni/src/jawtable.c
+++ b/jni/src/jawtable.c
@@ -98,12 +98,12 @@ jaw_table_data_init (jobject ac)
 
   JNIEnv *env = jaw_util_get_jni_env();
   jclass classTable = (*env)->FindClass(env, "org/GNOME/Accessibility/AtkTable");
-  jmethodID jmid = (*env)->GetMethodID(env,
+  jmethodID jmid = (*env)->GetStaticMethodID(env,
                                        classTable,
-                                       "<init>",
-                                       "(Ljavax/accessibility/AccessibleContext;)V");
+                                       "createAtkTable",
+                                       
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkTable;");
 
-  jobject jatk_table = (*env)->NewObject(env, classTable, jmid, ac);
+  jobject jatk_table = (*env)->CallStaticObjectMethod(env, classTable, jmid, ac);
   data->atk_table = (*env)->NewWeakGlobalRef(env, jatk_table);
 
   return data;
diff --git a/jni/src/jawtablecell.c b/jni/src/jawtablecell.c
index ca0fc9e..862c763 100644
--- a/jni/src/jawtablecell.c
+++ b/jni/src/jawtablecell.c
@@ -55,8 +55,8 @@ jaw_table_cell_data_init (jobject ac)
 
   JNIEnv *jniEnv = jaw_util_get_jni_env();
   jclass classTableCell = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkTableCell");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classTableCell, "<init>", 
"(Ljavax/accessibility/AccessibleContext;)V");
-  jobject jatk_table_cell = (*jniEnv)->NewObject(jniEnv, classTableCell, jmid, ac);
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv, classTableCell, "createAtkTableCell", 
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkTableCell;");
+  jobject jatk_table_cell = (*jniEnv)->CallStaticObjectMethod(jniEnv, classTableCell, jmid, ac);
   data->atk_table_cell = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_table_cell);
 
   return data;
@@ -219,4 +219,3 @@ jaw_table_cell_get_column_span(AtkTableCell *cell)
   (*env)->DeleteGlobalRef(env, jatk_table_cell);
   return ret;
 }
-
diff --git a/jni/src/jawtext.c b/jni/src/jawtext.c
index 2546e82..a6ea5c4 100644
--- a/jni/src/jawtext.c
+++ b/jni/src/jawtext.c
@@ -109,11 +109,11 @@ jaw_text_data_init (jobject ac)
   JNIEnv *jniEnv = jaw_util_get_jni_env();
   jclass classText = (*jniEnv)->FindClass(jniEnv,
                                           "org/GNOME/Accessibility/AtkText");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv,
                                           classText,
-                                          "<init>",
-                                          "(Ljavax/accessibility/AccessibleContext;)V");
-  jobject jatk_text = (*jniEnv)->NewObject(jniEnv, classText, jmid, ac);
+                                          "createAtkText",
+                                          
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkText;");
+  jobject jatk_text = (*jniEnv)->CallStaticObjectMethod(jniEnv, classText, jmid, ac);
   data->atk_text = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_text);
 
   return data;
@@ -604,4 +604,3 @@ jaw_text_set_caret_offset (AtkText *text, gint offset)
     return FALSE;
   }
 }
-
diff --git a/jni/src/jawvalue.c b/jni/src/jawvalue.c
index 1a997fc..1308328 100644
--- a/jni/src/jawvalue.c
+++ b/jni/src/jawvalue.c
@@ -53,11 +53,11 @@ jaw_value_data_init (jobject ac)
   JNIEnv *jniEnv = jaw_util_get_jni_env();
   jclass classValue = (*jniEnv)->FindClass(jniEnv,
                                            "org/GNOME/Accessibility/AtkValue");
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
+  jmethodID jmid = (*jniEnv)->GetStaticMethodID(jniEnv,
                                           classValue,
-                                          "<init>",
-                                          "(Ljavax/accessibility/AccessibleContext;)V");
-  jobject jatk_value = (*jniEnv)->NewObject(jniEnv, classValue, jmid, ac);
+                                          "createAtkValue",
+                                          
"(Ljavax/accessibility/AccessibleContext;)Lorg/GNOME/Accessibility/AtkValue;");
+  jobject jatk_value = (*jniEnv)->CallStaticObjectMethod(jniEnv, classValue, jmid, ac);
   data->atk_value = (*jniEnv)->NewWeakGlobalRef(jniEnv, jatk_value);
 
   return data;
@@ -239,4 +239,3 @@ jaw_value_get_increment (AtkValue *obj)
 #ifdef __cplusplus
 }
 #endif
-
diff --git a/wrapper/org/GNOME/Accessibility/AtkAction.java b/wrapper/org/GNOME/Accessibility/AtkAction.java
index eefb4b5..c28831b 100644
--- a/wrapper/org/GNOME/Accessibility/AtkAction.java
+++ b/wrapper/org/GNOME/Accessibility/AtkAction.java
@@ -39,27 +39,17 @@ public class AtkAction {
                }
        }
 
-       private class ActionRunner implements Runnable {
-               private AccessibleAction acc_action;
-               private int index;
-
-               public ActionRunner (AccessibleAction acc_action, int index) {
-                       this.acc_action = acc_action;
-                       this.index = index;
-               }
-
-               public void run () {
-                       acc_action.doAccessibleAction(index);
-               }
+       public static AtkAction createAtkAction(AccessibleContext ac){
+               return AtkUtil.invokeInSwing ( () -> { return new AtkAction(ac); }, null);
        }
 
        public boolean do_action (int i) {
-               SwingUtilities.invokeLater(new ActionRunner(acc_action, i));
+               AtkUtil.invokeInSwing( () -> { acc_action.doAccessibleAction(i); });
                return true;
        }
 
        public int get_n_actions () {
-               return acc_action.getAccessibleActionCount();
+               return AtkUtil.invokeInSwing( () -> { return acc_action.getAccessibleActionCount(); }, 0);
        }
 
        // FIXME: get and set methods seem wrong
@@ -95,19 +85,19 @@ public class AtkAction {
   *          name so a getter from the AcccessibleContext
   *          class is one way to work around that)
   */
-  public String getLocalizedName (int i) {
-    String name        = ac.getAccessibleName();
-    String description = acc_action.getAccessibleActionDescription(i);
-
-    if (description == name && description != null)
-      return description;
-    if (description == null && name != null)
-      return name;
-    else if (description != null)
-      return description;
-
-       return "";
-  }
+       public String getLocalizedName (int i) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       String name        = ac.getAccessibleName();
+                       String description = acc_action.getAccessibleActionDescription(i);
+                       if (description == name && description != null)
+                               return description;
+                       if (description == null && name != null)
+                               return name;
+                       if (description != null)
+                               return description;
+                       return "";
+               }, null);
+       }
 
        private String convertModString (String mods) {
                if (mods == null || mods.length() == 0) {
diff --git a/wrapper/org/GNOME/Accessibility/AtkComponent.java 
b/wrapper/org/GNOME/Accessibility/AtkComponent.java
index 6449dcc..8866cce 100644
--- a/wrapper/org/GNOME/Accessibility/AtkComponent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkComponent.java
@@ -38,97 +38,102 @@ public class AtkComponent {
     this.acc_component = ac.getAccessibleComponent();
   }
 
-  public boolean contains (int x, int y, int coord_type) {
-    if (coord_type == AtkCoordType.SCREEN) {
-      Point p = acc_component.getLocationOnScreen();
-      this.x -= p.x;
-      this.y -= p.y;
-    }
-
-    return acc_component.contains(new Point(x, y));
-  }
-
-  public AccessibleContext get_accessible_at_point (int x, int y, int coord_type) {
-    if (coord_type == AtkCoordType.SCREEN) {
-      Point p = acc_component.getLocationOnScreen();
-      this.x -= p.x;
-      this.y -= p.y;
-    }
-
-    Accessible accessible = acc_component.getAccessibleAt(new Point(x, y));
-    if (accessible == null) {
-      return null;
-    }
-
-    return accessible.getAccessibleContext();
-  }
-
-  public boolean grab_focus () {
-    if (!acc_component.isFocusTraversable()) {
-      return false;
-    }
-
-    acc_component.requestFocus();
-    return true;
-  }
-
-  public Point get_position (int coord_type) {
-    if (coord_type == AtkCoordType.SCREEN)
-      return acc_component.getLocationOnScreen();
-
-    return acc_component.getLocation();
+  public static AtkComponent createAtkComponent(AccessibleContext ac){
+      return AtkUtil.invokeInSwing ( () -> { return new AtkComponent(ac); }, null);
   }
 
-  public Rectangle set_extents(int x, int y, int width, int height, int coord_type) {
-    this.width  = (int)acc_component.getSize().getWidth();
-    this.height = (int)acc_component.getSize().getHeight();
-
-    if (coord_type == AtkCoordType.SCREEN) {
-      Point p = acc_component.getLocationOnScreen();
-    } else {
-      Point p = acc_component.getLocation();
-      this.x -= p.x;
-      this.y -= p.y;
-    }
-
-    return new Rectangle(x, y, width, height);
+  public boolean contains (int x, int y, int coord_type) {
+      return AtkUtil.invokeInSwing ( () -> {
+          if (coord_type == AtkCoordType.SCREEN) {
+              Point p = acc_component.getLocationOnScreen();
+              this.x -= p.x;
+              this.y -= p.y;
+          }
+          return acc_component.contains(new Point(x, y));
+      }, false);
   }
 
-  public Rectangle get_extents() {
-    Rectangle rect = acc_component.getBounds();
-    Point p = acc_component.getLocationOnScreen();
-    rect.x = p.x;
-    rect.y = p.y;
-    return rect;
+  public AccessibleContext get_accessible_at_point (int x, int y, int coord_type) {
+      return AtkUtil.invokeInSwing ( () -> {
+          if (coord_type == AtkCoordType.SCREEN) {
+              Point p = acc_component.getLocationOnScreen();
+              this.x -= p.x;
+              this.y -= p.y;
+          }
+          Accessible accessible = acc_component.getAccessibleAt(new Point(x, y));
+          if (accessible == null)
+              return null;
+          return accessible.getAccessibleContext();
+      }, null);
   }
 
-  public int get_layer () {
-    AccessibleRole role = ac.getAccessibleRole();
-
-    if (role == AccessibleRole.MENU ||
-      role == AccessibleRole.MENU_ITEM ||
-      role == AccessibleRole.POPUP_MENU ) {
-      return AtkLayer.POPUP;
+    public boolean grab_focus () {
+        return AtkUtil.invokeInSwing ( () -> {
+            if (!acc_component.isFocusTraversable())
+                return false;
+            acc_component.requestFocus();
+            return true;
+        }, false);
     }
 
-    if (role == AccessibleRole.INTERNAL_FRAME) {
-      return AtkLayer.MDI;
+    public Point get_position (int coord_type) {
+        return AtkUtil.invokeInSwing ( () -> {
+            if (coord_type == AtkCoordType.SCREEN)
+                return acc_component.getLocationOnScreen();
+            return acc_component.getLocation();
+        }, null);
     }
 
-    if (role == AccessibleRole.GLASS_PANE) {
-      return AtkLayer.OVERLAY;
+    public Rectangle set_extents(int x, int y, int width, int height, int coord_type) {
+        return AtkUtil.invokeInSwing ( () -> {
+            Point p;
+            this.width  = (int)acc_component.getSize().getWidth();
+            this.height = (int)acc_component.getSize().getHeight();
+            if (coord_type == AtkCoordType.SCREEN)
+                p = acc_component.getLocationOnScreen();
+            else {
+                p = acc_component.getLocation();
+                this.x -= p.x;
+                this.y -= p.y;
+            }
+            return new Rectangle(x, y, width, height);
+        }, null);
     }
 
-    if (role == AccessibleRole.CANVAS ||
-      role == AccessibleRole.ROOT_PANE ||
-      role == AccessibleRole.LAYERED_PANE ) {
-      return AtkLayer.CANVAS;
+    public Rectangle get_extents() {
+        return AtkUtil.invokeInSwing ( () -> {
+            Rectangle rect = acc_component.getBounds();
+            Point p = acc_component.getLocationOnScreen();
+            rect.x = p.x;
+            rect.y = p.y;
+            return rect;
+        },null);
     }
 
-    if (role == AccessibleRole.WINDOW) {
-     return AtkLayer.WINDOW;
+    public int get_layer () {
+        return AtkUtil.invokeInSwing ( () -> {
+            AccessibleRole role = ac.getAccessibleRole();
+            if (role == AccessibleRole.MENU ||
+            role == AccessibleRole.MENU_ITEM ||
+            role == AccessibleRole.POPUP_MENU ) {
+                return AtkLayer.POPUP;
+            }
+            if (role == AccessibleRole.INTERNAL_FRAME) {
+                return AtkLayer.MDI;
+            }
+            if (role == AccessibleRole.GLASS_PANE) {
+                return AtkLayer.OVERLAY;
+            }
+            if (role == AccessibleRole.CANVAS ||
+            role == AccessibleRole.ROOT_PANE ||
+            role == AccessibleRole.LAYERED_PANE ) {
+                return AtkLayer.CANVAS;
+            }
+            if (role == AccessibleRole.WINDOW) {
+                return AtkLayer.WINDOW;
+            }
+            return AtkLayer.WIDGET;
+        }, AtkLayer.INVALID);
     }
 
-    return AtkLayer.WIDGET;
-  }
 }
diff --git a/wrapper/org/GNOME/Accessibility/AtkEditableText.java 
b/wrapper/org/GNOME/Accessibility/AtkEditableText.java
index f8f2a6f..273c633 100644
--- a/wrapper/org/GNOME/Accessibility/AtkEditableText.java
+++ b/wrapper/org/GNOME/Accessibility/AtkEditableText.java
@@ -33,68 +33,73 @@ public class AtkEditableText extends AtkText {
     acc_edt_text = ac.getAccessibleEditableText();
   }
 
-  public void set_text_contents (String s) {
-    if (!javax.swing.SwingUtilities.isEventDispatchThread()) {
-      System.out.println("** WARNING: setting text contents outside from EDT, this will *break* applications 
which do not support thread safety");
-    }
-    acc_edt_text.setTextContents(s);
+  public static AtkEditableText createAtkEditableText(AccessibleContext ac){
+      return AtkUtil.invokeInSwing ( () -> { return new AtkEditableText(ac); }, null);
   }
 
-  public void insert_text (String s, int position) {
-    if (position < 0) {
-      position = 0;
-    }
-
-    acc_edt_text.insertTextAtIndex(position, s);
+  public void set_text_contents (String s) {
+      if (!javax.swing.SwingUtilities.isEventDispatchThread())
+        System.out.println("It would be unsafe to call setTextContents here");
+      AtkUtil.invokeInSwing( () -> {
+          acc_edt_text.setTextContents(s);
+      });
   }
 
-  public void copy_text (int start, int end) {
-    int n = acc_edt_text.getCharCount();
-
-    if (start < 0) {
-      start = 0;
+    public void insert_text (String s, int position) {
+        if (position < 0)
+            position = 0;
+        final int rightPosition = position;
+        AtkUtil.invokeInSwing( () -> { acc_edt_text.insertTextAtIndex(rightPosition, s); });
     }
 
-    if (end > n || end == -1) {
-      end = n;
-    } else if (end < -1) {
-      end = 0;
+    public void copy_text (int start, int end) {
+        int n = acc_edt_text.getCharCount();
+        if (start < 0) {
+            start = 0;
+        }
+        if (end > n || end == -1) {
+            end = n;
+        } else if (end < -1) {
+            end = 0;
+        }
+        final int rightStart = start;
+        final int rightEnd = end;
+        AtkUtil.invokeInSwing ( () -> {
+            String s = acc_edt_text.getTextRange(rightStart, rightEnd);
+            if (s != null) {
+                StringSelection stringSel = new StringSelection(s);
+                Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSel, stringSel);
+            }
+        });
     }
 
-    String s = acc_edt_text.getTextRange(start, end);
-    if (s != null) {
-      StringSelection stringSel = new StringSelection(s);
-      Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSel,
-                                                                   stringSel
-                                                                   );
+    public void cut_text (int start, int end) {
+        AtkUtil.invokeInSwing( () -> { acc_edt_text.cut(start, end); });
     }
-  }
 
-  public void cut_text (int start, int end) {
-    acc_edt_text.cut(start, end);
-  }
+    public void delete_text (int start, int end) {
+        AtkUtil.invokeInSwing( () -> { acc_edt_text.delete(start, end); });
+    }
 
-  public void delete_text (int start, int end) {
-    acc_edt_text.delete(start, end);
-  }
+    public void paste_text (int position) {
+        AtkUtil.invokeInSwing( () -> { acc_edt_text.paste(position); });
+    }
 
-  public void paste_text (int position) {
-    acc_edt_text.paste(position);
-  }
+    /**
+    * Sets run attributes for the text between two indices.
+    *
+    * @param as the AttributeSet for the text
+    * @param start the start index of the text as an int
+    * @param end the end index for the text as an int
+    * @return whether setRunAttributes was called
+    * TODO return is a bit presumptious. This should ideally include a check for whether
+    *      attributes were set.
+    */
+    public boolean setRunAttributes(AttributeSet as, int start, int end) {
+        return AtkUtil.invokeInSwing( () -> {
+            acc_edt_text.setAttributes(start, end, as);
+            return true;
+        }, false);
+    }
 
- /**
-  * Sets run attributes for the text between two indices.
-  *
-  * @param as the AttributeSet for the text
-  * @param start the start index of the text as an int
-  * @param end the end index for the text as an int
-  * @return whether setRunAttributes was called
-  *              TODO return is a bit presumptious. This should ideally include a check for whether
-  *              attributes were set.
-  */
-  public boolean setRunAttributes(AttributeSet as, int start, int end) {
-    acc_edt_text.setAttributes(start, end, as);
-    return true;
-  }
 }
-
diff --git a/wrapper/org/GNOME/Accessibility/AtkHyperlink.java 
b/wrapper/org/GNOME/Accessibility/AtkHyperlink.java
index 714af45..ad71dc8 100644
--- a/wrapper/org/GNOME/Accessibility/AtkHyperlink.java
+++ b/wrapper/org/GNOME/Accessibility/AtkHyperlink.java
@@ -30,39 +30,41 @@ public class AtkHyperlink {
                acc_hyperlink = hl;
        }
 
-       public String get_uri (int i) {
-               String s = "";
-               Object o = acc_hyperlink.getAccessibleActionObject(i);
-               if (o != null) {
-                       s = o.toString();
-               }
+       public static AtkHyperlink createAtkHyperlink(AccessibleHyperlink hl){
+        return AtkUtil.invokeInSwing ( () -> { return new AtkHyperlink(hl); }, null);
+    }
 
-               return s;
+       public String get_uri (int i) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       Object o = acc_hyperlink.getAccessibleActionObject(i);
+                       if (o != null)
+                               return o.toString();
+                       return "";
+               }, "");
        }
 
        public Object get_object (int i) {
-               Object o = null;
-               Object anchor = acc_hyperlink.getAccessibleActionAnchor(i);
-               if (anchor instanceof Accessible) {
-                       o = anchor;
-               }
-
-               return o;
+               return AtkUtil.invokeInSwing ( () -> {
+                       Object anchor = acc_hyperlink.getAccessibleActionAnchor(i);
+                       if (anchor instanceof Accessible)
+                               return anchor;
+                       return null;
+               }, null);
        }
 
        public int get_end_index () {
-               return acc_hyperlink.getEndIndex();
+               return AtkUtil.invokeInSwing ( () -> { return acc_hyperlink.getEndIndex(); }, 0);
        }
 
        public int get_start_index () {
-               return acc_hyperlink.getStartIndex();
+               return AtkUtil.invokeInSwing ( () -> { return acc_hyperlink.getStartIndex(); }, 0);
        }
 
        public boolean is_valid () {
-               return acc_hyperlink.isValid();
+               return AtkUtil.invokeInSwing ( () -> { return acc_hyperlink.isValid(); }, false);
        }
 
        public int get_n_anchors () {
-               return acc_hyperlink.getAccessibleActionCount();
+               return AtkUtil.invokeInSwing ( () -> { return acc_hyperlink.getAccessibleActionCount(); }, 0);
        }
 }
diff --git a/wrapper/org/GNOME/Accessibility/AtkHypertext.java 
b/wrapper/org/GNOME/Accessibility/AtkHypertext.java
index 695b0ca..98b6055 100644
--- a/wrapper/org/GNOME/Accessibility/AtkHypertext.java
+++ b/wrapper/org/GNOME/Accessibility/AtkHypertext.java
@@ -36,35 +36,34 @@ public class AtkHypertext extends AtkText {
                }
        }
 
+       public static AtkHypertext createAtkHypertext(AccessibleContext ac){
+        return AtkUtil.invokeInSwing ( () -> { return new AtkHypertext(ac); }, null);
+    }
+
        public AtkHyperlink get_link (int link_index) {
-               if (acc_hyper_text != null) {
-                       AccessibleHyperlink link = acc_hyper_text.getLink(link_index);
-                       if (link != null) {
-                               return new AtkHyperlink(link);
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (acc_hyper_text != null) {
+                               AccessibleHyperlink link = acc_hyper_text.getLink(link_index);
+                               if (link != null)
+                                       return new AtkHyperlink(link);
                        }
-               }
-
-               return null;
+                       return null;
+               }, null);
        }
 
        public int get_n_links () {
-               int nLinks = 0;
-
-               if (acc_hyper_text != null) {
-                       nLinks = acc_hyper_text.getLinkCount();
-               }
-
-               return nLinks;
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (acc_hyper_text != null)
+                               return acc_hyper_text.getLinkCount();
+                       return 0;
+               }, 0);
        }
 
        public int get_link_index (int char_index) {
-               int index = 0;
-
-               if (acc_hyper_text != null) {
-                       index = acc_hyper_text.getLinkIndex(char_index);
-               }
-
-               return index;
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (acc_hyper_text != null)
+                               return acc_hyper_text.getLinkIndex(char_index);
+                       return 0;
+               }, 0);
        }
 }
-
diff --git a/wrapper/org/GNOME/Accessibility/AtkImage.java b/wrapper/org/GNOME/Accessibility/AtkImage.java
index 1d7cd40..4325849 100644
--- a/wrapper/org/GNOME/Accessibility/AtkImage.java
+++ b/wrapper/org/GNOME/Accessibility/AtkImage.java
@@ -33,41 +33,42 @@ public class AtkImage {
                this.ac = ac;
                this.acc_icons = ac.getAccessibleIcon();
        }
-       
-       public Point get_image_position (int coord_type) {
-               AccessibleComponent acc_component = ac.getAccessibleComponent();
-               if (acc_component == null) {
-                       return null;
-               }
 
-               if (coord_type == AtkCoordType.SCREEN) {
-                       return acc_component.getLocationOnScreen();
-               }
+       public static AtkImage createAtkImage(AccessibleContext ac){
+        return AtkUtil.invokeInSwing ( () -> { return new AtkImage(ac); }, null);
+    }
 
-               return acc_component.getLocation();
+       public Point get_image_position (int coord_type) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleComponent acc_component = ac.getAccessibleComponent();
+                       if (acc_component == null)
+                               return null;
+                       if (coord_type == AtkCoordType.SCREEN)
+                               return acc_component.getLocationOnScreen();
+                       return acc_component.getLocation();
+               }, null);
        }
 
        public String get_image_description () {
-               String desc = "";
-               if (acc_icons != null && acc_icons.length > 0) {
-                       desc = acc_icons[0].getAccessibleIconDescription();
-
-                       if (desc == null) {
-                               desc = "";
+               return AtkUtil.invokeInSwing ( () -> {
+                       String desc = "";
+                       if (acc_icons != null && acc_icons.length > 0) {
+                               desc = acc_icons[0].getAccessibleIconDescription();
+                               if (desc == null)
+                                       desc = "";
                        }
-               }
-
-               return desc;
+                       return desc;
+               }, "");
        }
 
        public Dimension get_image_size () {
                Dimension d = new Dimension(0, 0);
-               if (acc_icons != null && acc_icons.length > 0) {
-                       d.height = acc_icons[0].getAccessibleIconHeight();
-                       d.width = acc_icons[0].getAccessibleIconWidth();
-               }
-
-               return d;
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (acc_icons != null && acc_icons.length > 0) {
+                               d.height = acc_icons[0].getAccessibleIconHeight();
+                               d.width = acc_icons[0].getAccessibleIconWidth();
+                       }
+                       return d;
+               },d);
        }
 }
-
diff --git a/wrapper/org/GNOME/Accessibility/AtkSelection.java 
b/wrapper/org/GNOME/Accessibility/AtkSelection.java
index 5e72b3c..fd1e18b 100644
--- a/wrapper/org/GNOME/Accessibility/AtkSelection.java
+++ b/wrapper/org/GNOME/Accessibility/AtkSelection.java
@@ -32,49 +32,58 @@ public class AtkSelection {
                this.acc_selection = ac.getAccessibleSelection();
        }
 
+       public static AtkSelection createAtkSelection(AccessibleContext ac){
+        return AtkUtil.invokeInSwing ( () -> { return new AtkSelection(ac); }, null);
+    }
+
        public boolean add_selection (int i) {
-               acc_selection.addAccessibleSelection(i);
-               return is_child_selected(i);
+               return AtkUtil.invokeInSwing( () -> {
+                       acc_selection.addAccessibleSelection(i);
+                       return is_child_selected(i);
+               }, false);
        }
 
        public boolean clear_selection () {
-               acc_selection.clearAccessibleSelection();
+               AtkUtil.invokeInSwing( () -> { acc_selection.clearAccessibleSelection(); });
                return true;
        }
 
        public Accessible ref_selection (int i) {
-               return acc_selection.getAccessibleSelection(i);
+               return AtkUtil.invokeInSwing ( () -> { return acc_selection.getAccessibleSelection(i); }, 
null);
        }
 
        public int get_selection_count () {
-               int count = 0;
-               for(int i = 0; i < ac.getAccessibleChildrenCount(); i++) {
-                       if (acc_selection.isAccessibleChildSelected(i))
-                               count++;
-               }
-
-               return count;
+               return AtkUtil.invokeInSwing ( () -> {
+                       int count = 0;
+                       for(int i = 0; i < ac.getAccessibleChildrenCount(); i++) {
+                               if (acc_selection.isAccessibleChildSelected(i))
+                                       count++;
+                       }
+                       return count;
+               }, 0);
                //A bug in AccessibleJMenu??
                //return acc_selection.getAccessibleSelectionCount();
        }
 
        public boolean is_child_selected (int i) {
-               return acc_selection.isAccessibleChildSelected(i);
+               return AtkUtil.invokeInSwing ( () -> { return acc_selection.isAccessibleChildSelected(i); }, 
false);
        }
 
        public boolean remove_selection (int i) {
-               acc_selection.removeAccessibleSelection(i);
-               return !is_child_selected(i);
+               return AtkUtil.invokeInSwing( () -> {
+                       acc_selection.removeAccessibleSelection(i);
+                       return !is_child_selected(i);
+               }, false);
        }
 
        public boolean select_all_selection () {
                AccessibleStateSet stateSet = ac.getAccessibleStateSet();
-
-               if (stateSet.contains(AccessibleState.MULTISELECTABLE)) {
-                       acc_selection.selectAllAccessibleSelection();
-                       return true;
-               }
-
-               return false;
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (stateSet.contains(AccessibleState.MULTISELECTABLE)) {
+                               acc_selection.selectAllAccessibleSelection();
+                               return true;
+                       }
+                       return false;
+               }, false);
        }
 }
diff --git a/wrapper/org/GNOME/Accessibility/AtkTable.java b/wrapper/org/GNOME/Accessibility/AtkTable.java
index 006286f..21624da 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTable.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTable.java
@@ -32,59 +32,60 @@ public class AtkTable {
     this.acc_table = ac.getAccessibleTable();
   }
 
-       public AccessibleContext ref_at (int row, int column) {
-               Accessible accessible = acc_table.getAccessibleAt(row, column);
-               if (accessible != null) {
-                       return accessible.getAccessibleContext();
-               }
+       public static AtkTable createAtkTable(AccessibleContext ac){
+               return AtkUtil.invokeInSwing ( () -> { return new AtkTable(ac); }, null);
+       }
 
-               return null;
+       public AccessibleContext ref_at (int row, int column) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       Accessible accessible = acc_table.getAccessibleAt(row, column);
+                       if (accessible != null)
+                               return accessible.getAccessibleContext();
+                       return null;
+               }, null);
        }
 
        public int get_column_at_index (int index) {
-               int column = -1;
-
-               if (acc_table instanceof AccessibleExtendedTable) {
-                       column = ((AccessibleExtendedTable)acc_table).getAccessibleColumn(index);
-               }
-
-               return column;
+               return AtkUtil.invokeInSwing ( () -> {
+                       int column = -1;
+                       if (acc_table instanceof AccessibleExtendedTable)
+                               column = ( (AccessibleExtendedTable) acc_table).getAccessibleColumn(index);
+                       return column;
+               }, -1);
        }
 
        public int get_row_at_index (int index) {
-               int row = -1;
-
-               if (acc_table instanceof AccessibleExtendedTable) {
-                       row = ((AccessibleExtendedTable)acc_table).getAccessibleRow(index);
-               }
-
-               return row;
+               return AtkUtil.invokeInSwing ( () -> {
+                       int row = -1;
+                       if (acc_table instanceof AccessibleExtendedTable)
+                               row = ( (AccessibleExtendedTable) acc_table).getAccessibleRow(index);
+                       return row;
+               }, -1);
        }
 
        public int get_n_columns () {
-               return acc_table.getAccessibleColumnCount();
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.getAccessibleColumnCount(); }, 0);
        }
 
        public int get_n_rows () {
-               return acc_table.getAccessibleRowCount();
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.getAccessibleRowCount(); }, 0);
        }
 
        public int get_column_extent_at (int row, int column) {
-               return acc_table.getAccessibleColumnExtentAt(row, column);
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.getAccessibleColumnExtentAt(row, 
column); }, 0);
        }
 
        public int get_row_extent_at (int row, int column) {
-               return acc_table.getAccessibleRowExtentAt(row, column);
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.getAccessibleRowExtentAt(row, 
column); }, 0);
        }
 
        public AccessibleContext get_caption () {
-               Accessible accessible = acc_table.getAccessibleCaption();
-
-               if (accessible != null) {
-                       return accessible.getAccessibleContext();
-               }
-
-               return null;
+               return AtkUtil.invokeInSwing ( () -> {
+                       Accessible accessible = acc_table.getAccessibleCaption();
+                       if (accessible != null)
+                               return accessible.getAccessibleContext();
+                       return null;
+               }, null);
        }
 
     /**
@@ -92,76 +93,71 @@ public class AtkTable {
      * @param a an Accessible object
      */
     public void setCaption(Accessible a) {
-        acc_table.setAccessibleCaption(a);
+        AtkUtil.invokeInSwing( () -> { acc_table.setAccessibleCaption(a); });
     }
 
        public String get_column_description (int column) {
-               Accessible accessible =
-                       acc_table.getAccessibleColumnDescription(column);
-
-               if (accessible != null) {
-                       AccessibleContext ac = accessible.getAccessibleContext();
-                       if (ac != null) {
-                               return ac.getAccessibleDescription();
+               return AtkUtil.invokeInSwing ( () -> {
+                       Accessible accessible = acc_table.getAccessibleColumnDescription(column);
+                       if (accessible != null) {
+                               AccessibleContext ac = accessible.getAccessibleContext();
+                               if (ac != null)
+                                       return ac.getAccessibleDescription();
                        }
-               }
-
-               return "";
+                       return "";
+               }, "");
        }
 
-/**
- *
- * @param column an int representing a column in table
- * @param description a String object representing the description text to set for the
- *                    specified column of the table
- */
-  public void setColumnDescription(int column, String description) {
-    Accessible accessible = acc_table.getAccessibleColumnDescription(column);
-    if (description.equals(accessible.toString()) && accessible != null) {
-      acc_table.setAccessibleColumnDescription(column, accessible);
-    }
-  }
+       /**
+       *
+       * @param column an int representing a column in table
+       * @param description a String object representing the description text to set for the
+       *                    specified column of the table
+       */
+       public void setColumnDescription(int column, String description) {
+               AtkUtil.invokeInSwing( () -> {
+                       Accessible accessible = acc_table.getAccessibleColumnDescription(column);
+                       if (description.equals(accessible.toString()) && accessible != null)
+                               acc_table.setAccessibleColumnDescription(column, accessible);
+               });
+       }
 
        public String get_row_description (int row) {
-               Accessible accessible =
-                       acc_table.getAccessibleRowDescription(row);
-
-               if (accessible != null) {
-                       AccessibleContext ac = accessible.getAccessibleContext();
-                       if (ac != null) {
-                               return ac.getAccessibleDescription();
+               return AtkUtil.invokeInSwing ( () -> {
+                       Accessible accessible = acc_table.getAccessibleRowDescription(row);
+                       if (accessible != null) {
+                               AccessibleContext ac = accessible.getAccessibleContext();
+                               if (ac != null)
+                                       return ac.getAccessibleDescription();
                        }
-               }
-
-               return "";
+                       return "";
+               }, "");
        }
 
- /**
-  *
-  * @param row an int representing a row in table
-  * @param description a String object representing the description text to set for the
-  *                    specified row of the table
-  */
-  public void setRowDescription(int row, String description) {
-    Accessible accessible = acc_table.getAccessibleRowDescription(row);
-    if (description.equals(accessible.toString()) && accessible != null) {
-      acc_table.setAccessibleRowDescription(row, accessible);
-    }
-  }
+       /**
+       *
+       * @param row an int representing a row in table
+       * @param description a String object representing the description text to set for the
+       *                    specified row of the table
+       */
+       public void setRowDescription(int row, String description) {
+               AtkUtil.invokeInSwing( () -> {
+                       Accessible accessible = acc_table.getAccessibleRowDescription(row);
+                       if (description.equals(accessible.toString()) && accessible != null)
+                               acc_table.setAccessibleRowDescription(row, accessible);
+               });
+       }
 
        public AccessibleContext get_column_header (int column) {
-               AccessibleTable accessibleTable =
-                       acc_table.getAccessibleColumnHeader();
-
-               if (accessibleTable != null) {
-                       Accessible accessible = accessibleTable.getAccessibleAt(0, column);
-
-                       if (accessible != null) {
-                               return accessible.getAccessibleContext();
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleTable accessibleTable = acc_table.getAccessibleColumnHeader();
+                       if (accessibleTable != null) {
+                               Accessible accessible = accessibleTable.getAccessibleAt(0, column);
+                               if (accessible != null)
+                                       return accessible.getAccessibleContext();
                        }
-               }
-
-               return null;
+                       return null;
+               }, null);
        }
 
     /**
@@ -171,36 +167,32 @@ public class AtkTable {
      */
     public void setColumnHeader (int column, AccessibleTable table) {
        // FIXME: this isn't using column for anything
-        acc_table.setAccessibleColumnHeader(table);
+        AtkUtil.invokeInSwing( () -> { acc_table.setAccessibleColumnHeader(table); });
     }
 
        public AccessibleContext get_row_header (int row) {
-               AccessibleTable accessibleTable =
-                       acc_table.getAccessibleRowHeader();
-
-               if (accessibleTable != null) {
-                       Accessible accessible = accessibleTable.getAccessibleAt(row, 0);
-
-                       if (accessible != null) {
-                               return accessible.getAccessibleContext();
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleTable accessibleTable = acc_table.getAccessibleRowHeader();
+                       if (accessibleTable != null) {
+                               Accessible accessible = accessibleTable.getAccessibleAt(row, 0);
+                               if (accessible != null)
+                                       return accessible.getAccessibleContext();
                        }
-               }
-
-               return null;
+                       return null;
+               }, null);
        }
 
     public void setRowHeader (int row, AccessibleTable table) {
-        acc_table.setAccessibleRowHeader(table);
+        AtkUtil.invokeInSwing( () -> { acc_table.setAccessibleRowHeader(table); });
     }
 
        public AccessibleContext get_summary () {
-               Accessible accessible = acc_table.getAccessibleSummary();
-
-               if (accessible != null) {
-                       return accessible.getAccessibleContext();
-               }
-
-               return null;
+               return AtkUtil.invokeInSwing ( () -> {
+                       Accessible accessible = acc_table.getAccessibleSummary();
+                       if (accessible != null)
+                               return accessible.getAccessibleContext();
+                       return null;
+               }, null);
        }
 
     /**
@@ -208,27 +200,29 @@ public class AtkTable {
      * @param a the Accessible object to set summary for
      */
     public void setSummary(Accessible a) {
-        acc_table.setAccessibleSummary(a);
+        AtkUtil.invokeInSwing( () -> { acc_table.setAccessibleSummary(a); });
     }
 
        public int[] get_selected_columns () {
-               return acc_table.getSelectedAccessibleColumns();
+               int[] d = new int[0];
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.getSelectedAccessibleColumns(); }, d);
        }
 
        public int[] get_selected_rows () {
-               return acc_table.getSelectedAccessibleRows();
+               int[] d = new int[0];
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.getSelectedAccessibleRows(); }, d);
        }
 
        public boolean is_column_selected (int column) {
-               return acc_table.isAccessibleColumnSelected(column);
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.isAccessibleColumnSelected(column); 
}, false);
        }
 
        public boolean is_row_selected (int row) {
-               return acc_table.isAccessibleRowSelected(row);
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.isAccessibleRowSelected(row); }, 
false);
        }
 
        public boolean is_selected (int row, int column) {
-               return acc_table.isAccessibleSelected(row, column);
+               return AtkUtil.invokeInSwing ( () -> { return acc_table.isAccessibleSelected(row, column); } 
,false);
        }
 
   public boolean addColumnSelection (int column) {
diff --git a/wrapper/org/GNOME/Accessibility/AtkTableCell.java 
b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
index 62a0484..9000fe7 100644
--- a/wrapper/org/GNOME/Accessibility/AtkTableCell.java
+++ b/wrapper/org/GNOME/Accessibility/AtkTableCell.java
@@ -42,61 +42,72 @@ public class AtkTableCell extends AtkTable {
     columnSpan = 0;
   }
 
-/**
- * getTable
- * @return: Reference to the accessible of the containing table as an
- *          AccessibleTable instance.
- */
-  public AccessibleTable getTable() {
-    System.out.println("Get Table: " + acc_table_cell.toString());
-    return acc_table_cell;
+  public static AtkTableCell createAtkTableCell(AccessibleContext ac){
+      return AtkUtil.invokeInSwing ( () -> { return new AtkTableCell(ac); }, null);
   }
 
-/**
- * @param row the row of the accessible table cell
- * @param column the column of the accessible table cell
- * @return: whether the accessible index of the table cell is found
- */
-  public boolean getPosition(int row, int column) {
-    int index = acc_table_cell.getAccessibleIndex(row, column);
-    if (index < 0)
-      return false;
-    return true;
-  }
+    /**
+    * getTable
+    * @return: Reference to the accessible of the containing table as an
+    *          AccessibleTable instance.
+    */
+    public AccessibleTable getTable() {
+        return AtkUtil.invokeInSwing ( () -> { return acc_table_cell; }, null);
+    }
 
-/**
- * @param row the row of the accessible table cell
- * @param column the column of the accessible table cell
- * @param rowSpan the row span of the accessible table cell the
- * @param columnSpan the column span of the accessible table cell
- * @return: whether the column and row span was retrieved
- */
-  public boolean getRowColumnSpan(int row, int column, int rowSpan, int columnSpan) {
-    this.rowSpan = rowSpan;
-    this.columnSpan = columnSpan;
-    rowSpan = acc_table.getAccessibleRowExtentAt(row, column);
-    columnSpan = acc_table.getAccessibleColumnExtentAt(row, column);
-    if (rowSpan < 0 && columnSpan < 0)
-      return false;
-    return true;
-  }
+  /**
+  * @param row the row of the accessible table cell
+  * @param column the column of the accessible table cell
+  * @return: whether the accessible index of the table cell is found
+  */
+    public boolean getPosition(int row, int column) {
+        return AtkUtil.invokeInSwing ( () -> {
+            int index = acc_table_cell.getAccessibleIndex(row, column);
+            if (index < 0)
+                return false;
+            return true;
+        }, false);
+    }
 
-/**
- * @return: span of the table_cell row as an int
- */
-  public int getRowSpan() {
-    if (rowSpan < 0)
-      return -1;
-    return rowSpan;
-  }
+    /**
+    * @param row the row of the accessible table cell
+    * @param column the column of the accessible table cell
+    * @param rowSpan the row span of the accessible table cell the
+    * @param columnSpan the column span of the accessible table cell
+    * @return: whether the column and row span was retrieved
+    */
+    public boolean getRowColumnSpan(int row, int column, int rowSpan, int columnSpan) {
+        return AtkUtil.invokeInSwing ( () -> {
+            this.rowSpan = rowSpan;
+            this.columnSpan = columnSpan;
+            int chekRowSpan = acc_table.getAccessibleRowExtentAt(row, column);
+            int checkColumnSpan = acc_table.getAccessibleColumnExtentAt(row, column);
+            if (chekRowSpan < 0 && checkColumnSpan < 0)
+                return false;
+            return true;
+        }, false);
+    }
 
-/**
- * @return: span of the table_cell column as an int
- */
-  public int getColumnSpan() {
-    if (columnSpan < 0)
-      return -1;
-    return columnSpan;
-  }
-}
+    /**
+    * @return: span of the table_cell row as an int
+    */
+    public int getRowSpan() {
+        return AtkUtil.invokeInSwing ( () -> {
+            if (rowSpan < 0)
+                return -1;
+            return rowSpan;
+        }, -1);
+    }
+
+    /**
+    * @return: span of the table_cell column as an int
+    */
+    public int getColumnSpan() {
+        return AtkUtil.invokeInSwing ( () -> {
+            if (columnSpan < 0)
+                return -1;
+            return columnSpan;
+        }, -1);
+    }
 
+}
diff --git a/wrapper/org/GNOME/Accessibility/AtkText.java b/wrapper/org/GNOME/Accessibility/AtkText.java
index 57d6b6d..545c624 100644
--- a/wrapper/org/GNOME/Accessibility/AtkText.java
+++ b/wrapper/org/GNOME/Accessibility/AtkText.java
@@ -47,196 +47,180 @@ public class AtkText {
                this.acc_text = ac.getAccessibleText();
        }
 
+       public static AtkText createAtkText(AccessibleContext ac){
+        return AtkUtil.invokeInSwing ( () -> { return new AtkText(ac); }, null);
+    }
+
        /* Return string from start, up to, but not including end */
        public String get_text (int start, int end) {
-               int count = acc_text.getCharCount();
-               if (start < 0)
-                       start = 0;
-
-               if (end > count || end ==-1)
-                       end = count;
-               if (end < -1)
-                       end = 0;
-
-               if (acc_text instanceof AccessibleExtendedText) {
-                       AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
-                       return acc_ext_text.getTextRange(start, end);
-               }
-
-               StringBuffer buf = new StringBuffer();
-               for (int i = start; i <= end-1; i++) {
-                       String str = acc_text.getAtIndex(
-                                       AccessibleText.CHARACTER, i);
-                       buf.append(str);
-               }
-
-               return buf.toString();
+               return AtkUtil.invokeInSwing ( () -> {
+                       int count = acc_text.getCharCount();
+                       final int rightStart;
+                       if (start < 0)
+                               rightStart = 0;
+                       else
+                               rightStart = start;
+                       final int rightEnd;
+                       if (end > count || end ==-1)
+                               rightEnd = count;
+                       else if (end < -1)
+                               rightEnd = 0;
+                               else
+                               rightEnd = end;
+                       if (acc_text instanceof AccessibleExtendedText) {
+                               AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
+                               return acc_ext_text.getTextRange(rightStart, rightEnd);
+                       }
+                       StringBuffer buf = new StringBuffer();
+                       for (int i = rightStart; i <= rightEnd-1; i++) {
+                               String str = acc_text.getAtIndex(AccessibleText.CHARACTER, i);
+                               buf.append(str);
+                       }
+                       return buf.toString();
+               }, null);
        }
 
        public char get_character_at_offset (int offset) {
-               String str =  acc_text.getAtIndex(
-                               AccessibleText.CHARACTER, offset);
-
-               if (str == null || str.length() == 0) {
-                       return 0;
-               }
-
-               return str.charAt(0);
+               return AtkUtil.invokeInSwing ( () -> {
+                       String str =  acc_text.getAtIndex(AccessibleText.CHARACTER, offset);
+                       if (str == null || str.length() == 0)
+                               return ' ';
+                       return str.charAt(0);
+               }, ' ');
        }
 
-       public StringSequence get_text_at_offset (int offset,
-                               int boundary_type) {
-               if (acc_text instanceof AccessibleExtendedText) {
-                       AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
-
-                       int part = getPartTypeFromBoundary(boundary_type);
-                       if (part == -1) {
-                               return null;
+       public StringSequence get_text_at_offset (int offset,int boundary_type) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (acc_text instanceof AccessibleExtendedText) {
+                               AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
+                               int part = getPartTypeFromBoundary(boundary_type);
+                               if (part == -1)
+                                       return null;
+                               AccessibleTextSequence seq = acc_ext_text.getTextSequenceAt(part, offset);
+                               return new StringSequence(seq.text, seq.startIndex, seq.endIndex+1);
+                       } else {
+                               return private_get_text_at_offset(offset, boundary_type);
                        }
-
-                       AccessibleTextSequence seq = acc_ext_text.getTextSequenceAt(part, offset);
-                       return new StringSequence(seq.text, seq.startIndex, seq.endIndex+1);
-
-
-               } else {
-                       return private_get_text_at_offset(offset, boundary_type);
-               }
+               }, null);
        }
 
        public int get_caret_offset () {
-               return acc_text.getCaretPosition();
+               return AtkUtil.invokeInSwing ( () -> { return acc_text.getCaretPosition(); }, 0);
        }
 
        public Rectangle get_character_extents (int offset, int coord_type) {
-               Rectangle rect = acc_text.getCharacterBounds(offset);
-               if (rect == null) {
-                       return null;
-               }
-
-               if (coord_type == AtkCoordType.SCREEN) {
-                       AccessibleComponent component = ac.getAccessibleComponent();
-                       if (component == null) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       Rectangle rect = acc_text.getCharacterBounds(offset);
+                       if (rect == null)
                                return null;
+                       if (coord_type == AtkCoordType.SCREEN) {
+                               AccessibleComponent component = ac.getAccessibleComponent();
+                               if (component == null)
+                                       return null;
+                               Point p = component.getLocationOnScreen();
+                               rect.x += p.x;
+                               rect.y += p.y;
                        }
-
-                       Point p = component.getLocationOnScreen();
-                       rect.x += p.x;
-                       rect.y += p.y;
-               }
-
-               return rect;
+                       return rect;
+               }, null);
        }
 
        public int get_character_count () {
-               return acc_text.getCharCount();
+               return AtkUtil.invokeInSwing ( () -> { return acc_text.getCharCount(); }, 0);
        }
 
-       public int get_offset_at_point (int x, int y,
-                               int coord_type) {
-               if (coord_type == AtkCoordType.SCREEN) {
-                       AccessibleComponent component = ac.getAccessibleComponent();
-                       if (component == null) {
-                               return -1;
+       public int get_offset_at_point (int x, int y, int coord_type) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (coord_type == AtkCoordType.SCREEN) {
+                               AccessibleComponent component = ac.getAccessibleComponent();
+                               if (component == null)
+                                       return -1;
+                               Point p = component.getLocationOnScreen();
+                               return acc_text.getIndexAtPoint(new Point(x-p.x, y-p.y));
                        }
-
-                       Point p = component.getLocationOnScreen();
-                       x -= p.x;
-                       y -= p.y;
-               }
-
-               return acc_text.getIndexAtPoint(new Point(x, y));
+                       return acc_text.getIndexAtPoint(new Point(x, y));
+               }, -1);
        }
 
-       public Rectangle get_range_extents (int start, int end,
-                                       int coord_type) {
-               if (acc_text instanceof AccessibleExtendedText) {
-                       AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
-                       Rectangle rect = acc_ext_text.getTextBounds(start, end-1);
-                       if (rect == null) {
-                               return null;
-                       }
-
-                       if (coord_type == AtkCoordType.SCREEN) {
-                               AccessibleComponent component = ac.getAccessibleComponent();
-                               if (component == null) {
+       public Rectangle get_range_extents (int start, int end, int coord_type) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       if (acc_text instanceof AccessibleExtendedText) {
+                               AccessibleExtendedText acc_ext_text = (AccessibleExtendedText)acc_text;
+                               Rectangle rect = acc_ext_text.getTextBounds(start, end-1);
+                               if (rect == null)
                                        return null;
+                               if (coord_type == AtkCoordType.SCREEN) {
+                                       AccessibleComponent component = ac.getAccessibleComponent();
+                                       if (component == null)
+                                               return null;
+                                       Point p = component.getLocationOnScreen();
+                                       rect.x += p.x;
+                                       rect.y += p.y;
                                }
-
-                               Point p = component.getLocationOnScreen();
-                               rect.x += p.x;
-                               rect.y += p.y;
+                               return rect;
                        }
-
-                       return rect;
-               } else {
                        return null;
-               }
+               }, null);
        }
 
        public int get_n_selections () {
-               String str = acc_text.getSelectedText();
-
-               if (str != null && str.length() > 0) {
-                       return 1;
-               } else {
+               return AtkUtil.invokeInSwing ( () -> {
+                       String str = acc_text.getSelectedText();
+                       if (str != null && str.length() > 0)
+                               return 1;
                        return 0;
-               }
+               }, 0);
        }
 
        public StringSequence get_selection () {
-               int start = acc_text.getSelectionStart();
-               int end = acc_text.getSelectionEnd() + 1;
-               String text = acc_text.getSelectedText();
-
-               if (text == null) {
-                       return null;
-               }
-
-               return new StringSequence(text, start, end);
+               return AtkUtil.invokeInSwing ( () -> {
+                       int start = acc_text.getSelectionStart();
+                       int end = acc_text.getSelectionEnd() + 1;
+                       String text = acc_text.getSelectedText();
+                       if (text == null)
+                               return null;
+                       return new StringSequence(text, start, end);
+               }, null);
        }
 
        public boolean add_selection (int start, int end) {
-               AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
-
-               if (acc_edt_text == null || get_n_selections() > 0) {
-                       return false;
-               }
-
-               return set_selection(0, start, end);
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
+                       if (acc_edt_text == null || get_n_selections() > 0)
+                               return false;
+                       return set_selection(0, start, end);
+               }, false);
        }
 
        public boolean remove_selection(int selection_num) {
-               AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
-
-               if (acc_edt_text == null || selection_num > 0) {
-                       return false;
-               }
-
-               acc_edt_text.selectText(0, 0);
-               return true;
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
+                       if (acc_edt_text == null || selection_num > 0)
+                               return false;
+                       acc_edt_text.selectText(0, 0);
+                       return true;
+               }, false);
        }
 
-       public boolean set_selection (int selection_num,
-                       int start, int end) {
-               AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
-
-               if (acc_edt_text == null || selection_num > 0) {
-                       return false;
-               }
-
-               acc_edt_text.selectText(start, end-1);
-               return true;
+       public boolean set_selection (int selection_num, int start, int end) {
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
+                       if (acc_edt_text == null || selection_num > 0)
+                               return false;
+                       acc_edt_text.selectText(start, end-1);
+                       return true;
+               }, false);
        }
 
        public boolean set_caret_offset (int offset) {
-               AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
-
-               if (acc_edt_text != null) {
-                       acc_edt_text.selectText(offset, offset);
-                       return true;
-               }
-
-               return false;
+               return AtkUtil.invokeInSwing ( () -> {
+                       AccessibleEditableText acc_edt_text = ac.getAccessibleEditableText();
+                       if (acc_edt_text != null) {
+                               acc_edt_text.selectText(offset, offset);
+                               return true;
+                       }
+                       return false;
+               }, false);
        }
 
        private int getPartTypeFromBoundary (int boundary_type) {
@@ -493,4 +477,3 @@ public class AtkText {
                }
        }
 }
-
diff --git a/wrapper/org/GNOME/Accessibility/AtkUtil.java b/wrapper/org/GNOME/Accessibility/AtkUtil.java
new file mode 100644
index 0000000..aa4a90d
--- /dev/null
+++ b/wrapper/org/GNOME/Accessibility/AtkUtil.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018, Red Hat, Inc.
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package org.GNOME.Accessibility;
+import javax.swing.*;
+import java.util.concurrent.*;
+
+/**
+* AtkUtil:
+*   That class is used to wrap the callback on Java object
+*   to avoid the concurrency of AWT objects.
+* @autor Giuseppe Capaldo
+*/
+public class AtkUtil{
+
+    /**
+    * invokeInSwing:
+    *   Invoked when we need to make an asynchronous callback on
+    *   a Java object and this callback has a return value.
+    *   this method doesn't launch any exception because in case
+    *   of problems it prints a warning and returns the default
+    *   value that is passed to it
+    *
+    * @param function A Callable object that return T value
+    * @param d A T object tha is returned if an exception occurs
+    * @return The return value of the original function or the
+    *       default value. Obviously if the value is a primitive type
+    *       this will automatically wrapped from java in the
+    *       corresponding object
+    */
+    public static <T> T invokeInSwing (Callable <T> function, T d){
+        RunnableFuture<T> wf = new FutureTask<>(function);
+        SwingUtilities.invokeLater(wf);
+        try {
+            return wf.get();
+        } catch (InterruptedException|ExecutionException ex) {
+            ex.printStackTrace(); // we can do better than this
+            return d;
+        }
+    }
+
+    /**
+    * invokeInSwing:
+    *   Invoked when we need to make an asynchronous callback on
+    *   some Java object and this callback hasn't a return value.
+    *
+    * @param function A Runnable object that doesn't return some value
+    */
+    public static void invokeInSwing (Runnable function){
+        SwingUtilities.invokeLater(function);
+    }
+
+}
diff --git a/wrapper/org/GNOME/Accessibility/AtkValue.java b/wrapper/org/GNOME/Accessibility/AtkValue.java
index 10b3440..b954dec 100644
--- a/wrapper/org/GNOME/Accessibility/AtkValue.java
+++ b/wrapper/org/GNOME/Accessibility/AtkValue.java
@@ -32,24 +32,27 @@ public class AtkValue {
                this.acc_value = ac.getAccessibleValue();
        }
 
+       public static AtkValue createAtkValue(AccessibleContext ac){
+        return AtkUtil.invokeInSwing ( () -> { return new AtkValue(ac); }, null);
+    }
+
        public Number get_current_value () {
-               return acc_value.getCurrentAccessibleValue();
+               return AtkUtil.invokeInSwing ( () -> { return acc_value.getCurrentAccessibleValue(); }, 0.0);
        }
 
        public double getMaximumValue () {
-               return acc_value.getMaximumAccessibleValue().doubleValue();
+               return AtkUtil.invokeInSwing ( () -> { return 
acc_value.getMaximumAccessibleValue().doubleValue(); }, 0.0);
        }
 
        public double getMinimumValue () {
-               return acc_value.getMinimumAccessibleValue().doubleValue();
+               return AtkUtil.invokeInSwing ( () -> { return 
acc_value.getMinimumAccessibleValue().doubleValue(); }, 0.0);
        }
 
   public void setValue (Number n) {
-    acc_value.setCurrentAccessibleValue(n);
+         AtkUtil.invokeInSwing( () -> { acc_value.setCurrentAccessibleValue(n); });
   }
 
   public double getIncrement() {
     return Double.MIN_VALUE;
   }
 }
-
diff --git a/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in 
b/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
index be02e4a..e997b70 100644
--- a/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
+++ b/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
@@ -28,6 +28,7 @@ import javax.accessibility.*;
 import java.awt.Toolkit;
 import javax.management.*;
 import java.util.*;
+import javax.swing.JComboBox;
 import java.lang.management.*;
 
 public class AtkWrapper {
@@ -83,8 +84,8 @@ public class AtkWrapper {
     */
     public void windowActivated(WindowEvent e) {
       Object o = e.getSource();
-      if ( o instanceof javax.accessibility.Accessible ) {
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+      if ( o instanceof Accessible ) {
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowActivate(ac);
       }
     }
@@ -102,8 +103,8 @@ public class AtkWrapper {
     */
     public void windowDeactivated(WindowEvent e) {
       Object o = e.getSource();
-      if (o instanceof javax.accessibility.Accessible) {
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+      if (o instanceof Accessible) {
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowDeactivate(ac);
       }
     }
@@ -116,8 +117,8 @@ public class AtkWrapper {
     */
     public void windowStateChanged(WindowEvent e) {
       Object o = e.getSource();
-      if (o instanceof javax.accessibility.Accessible) {
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+      if (o instanceof Accessible) {
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowStateChange(ac);
 
         if( (e.getNewState() & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH ) {
@@ -133,8 +134,8 @@ public class AtkWrapper {
     */
     public void windowDeiconified(WindowEvent e) {
       Object o = e.getSource();
-      if (o instanceof javax.accessibility.Accessible) {
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+      if (o instanceof Accessible) {
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowRestore(ac);
       }
     }
@@ -146,8 +147,8 @@ public class AtkWrapper {
     */
     public void windowIconified(WindowEvent e) {
       Object o = e.getSource();
-      if (o instanceof javax.accessibility.Accessible) {
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+      if (o instanceof Accessible) {
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowMinimize(ac);
       }
     }
@@ -158,9 +159,9 @@ public class AtkWrapper {
     */
     public void windowOpened(WindowEvent e) {
       Object o = e.getSource();
-      if ( o instanceof javax.accessibility.Accessible ) {
+      if ( o instanceof Accessible ) {
         boolean isToplevel = isToplevel(o);
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowOpen(ac, isToplevel);
       }
     }
@@ -172,9 +173,9 @@ public class AtkWrapper {
     */
     public void windowClosed(WindowEvent e) {
       Object o = e.getSource();
-      if (o instanceof javax.accessibility.Accessible) {
+      if (o instanceof Accessible) {
         boolean isToplevel = isToplevel(o);
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowClose(ac, isToplevel);
       }
     }
@@ -186,9 +187,9 @@ public class AtkWrapper {
     */
     public void windowClosing(WindowEvent e) {
       Object o = e.getSource();
-      if (o instanceof javax.accessibility.Accessible) {
+      if (o instanceof Accessible) {
         boolean isToplevel = isToplevel(o);
-        AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+        AccessibleContext ac = ((Accessible)o).getAccessibleContext();
         AtkWrapper.windowClose(ac, isToplevel);
       }
     }
@@ -218,8 +219,8 @@ public class AtkWrapper {
   */
   public void componentResized(ComponentEvent e) {
     Object o = e.getSource();
-    if (o instanceof javax.accessibility.Accessible) {
-      AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+    if (o instanceof Accessible) {
+      AccessibleContext ac = ((Accessible)o).getAccessibleContext();
       AtkWrapper.boundsChanged(ac);
     }
   }
@@ -233,8 +234,8 @@ public class AtkWrapper {
   */
   public void componentMoved(ComponentEvent e){
     Object o = e.getSource();
-    if (o instanceof javax.accessibility.Accessible) {
-      AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+    if (o instanceof Accessible) {
+      AccessibleContext ac = ((Accessible)o).getAccessibleContext();
       AtkWrapper.boundsChanged(ac);
     }
   }
@@ -245,8 +246,8 @@ public class AtkWrapper {
   */
   public void componentShown(ComponentEvent e) {
     Object o = e.getSource();
-    if (o instanceof javax.accessibility.Accessible) {
-      AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+    if (o instanceof Accessible) {
+      AccessibleContext ac = ((Accessible)o).getAccessibleContext();
       AtkWrapper.componentAdded(ac);
     }
   }
@@ -258,8 +259,8 @@ public class AtkWrapper {
   */
   public void componentHidden(ComponentEvent e){
     Object o = e.getSource();
-    if (o instanceof javax.accessibility.Accessible) {
-      AccessibleContext ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+    if (o instanceof Accessible) {
+      AccessibleContext ac = ((Accessible)o).getAccessibleContext();
       AtkWrapper.componentRemoved(ac);
     }
   }
@@ -313,13 +314,13 @@ public class AtkWrapper {
         switch( e.getID() ) {
           case ContainerEvent.COMPONENT_ADDED:
           {
-            java.awt.Component c = ((ContainerEvent)e).getChild();
+            Component c = ((ContainerEvent)e).getChild();
             c.addComponentListener(componentAdapter);
             break;
           }
           case ContainerEvent.COMPONENT_REMOVED:
           {
-           java.awt.Component c = ((ContainerEvent)e).getChild();
+               Component c = ((ContainerEvent)e).getChild();
             c.removeComponentListener(componentAdapter);
             break;
           }
@@ -358,8 +359,8 @@ public class AtkWrapper {
     try {
       if (eventSource instanceof AccessibleContext) {
         ctx = (AccessibleContext)eventSource;
-      } else if (eventSource instanceof javax.accessibility.Accessible) {
-        ctx = ((javax.accessibility.Accessible)eventSource).getAccessibleContext();
+      } else if (eventSource instanceof Accessible) {
+        ctx = ((Accessible)eventSource).getAccessibleContext();
       } else {
         return;
       }
@@ -395,8 +396,8 @@ public class AtkWrapper {
           Object child = accSelection.getAccessibleSelection(0);
           if (child instanceof AccessibleContext) {
             ctx = (AccessibleContext)child;
-          } else if (child instanceof javax.accessibility.Accessible) {
-            ctx = ((javax.accessibility.Accessible)child).getAccessibleContext();
+          } else if (child instanceof Accessible) {
+            ctx = ((Accessible)child).getAccessibleContext();
           } else {
             return;
           }
@@ -421,8 +422,8 @@ public class AtkWrapper {
       AccessibleContext ac;
       if (o instanceof AccessibleContext) {
         ac = (AccessibleContext)o;
-      } else if (o instanceof javax.accessibility.Accessible) {
-        ac = ((javax.accessibility.Accessible)o).getAccessibleContext();
+      } else if (o instanceof Accessible) {
+        ac = ((Accessible)o).getAccessibleContext();
       } else {
         return;
       }
@@ -480,8 +481,8 @@ public class AtkWrapper {
       } else if( propertyName.equals(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) ) {
         if (oldValue == null && newValue != null) { //child added
           AccessibleContext child_ac;
-          if (newValue instanceof javax.accessibility.Accessible) {
-            child_ac = ((javax.accessibility.Accessible)newValue).getAccessibleContext();
+          if (newValue instanceof Accessible) {
+            child_ac = ((Accessible)newValue).getAccessibleContext();
           } else {
             return;
           }
@@ -494,8 +495,8 @@ public class AtkWrapper {
 
         } else if (oldValue != null && newValue == null) { //child removed
           AccessibleContext child_ac;
-          if (oldValue instanceof javax.accessibility.Accessible) {
-            child_ac = ((javax.accessibility.Accessible)oldValue).getAccessibleContext();
+          if (oldValue instanceof Accessible) {
+            child_ac = ((Accessible)oldValue).getAccessibleContext();
           } else {
             return;
           }
@@ -509,8 +510,8 @@ public class AtkWrapper {
         }
       } else if( propertyName.equals(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) ) {
         AccessibleContext child_ac;
-        if (newValue instanceof javax.accessibility.Accessible) {
-          child_ac = ((javax.accessibility.Accessible)newValue).getAccessibleContext();
+        if (newValue instanceof Accessible) {
+          child_ac = ((Accessible)newValue).getAccessibleContext();
         } else {
           return;
         }
@@ -591,9 +592,9 @@ public class AtkWrapper {
         emitSignal(ac, AtkSignal.OBJECT_PROPERTY_CHANGE_ACCESSIBLE_TABLE_ROW_DESCRIPTION, null);
 
       } else if(propertyName.equals(AccessibleContext.ACCESSIBLE_STATE_PROPERTY)) {
-        javax.accessibility.Accessible parent = ac.getAccessibleParent();
-        javax.accessibility.AccessibleRole role = ac.getAccessibleRole();
-        javax.accessibility.AccessibleRole parent_role = null;
+        Accessible parent = ac.getAccessibleParent();
+        AccessibleRole role = ac.getAccessibleRole();
+        AccessibleRole parent_role = null;
         if (parent != null) {
           AccessibleContext parent_ac = parent.getAccessibleContext();
          if (parent_ac != null) {
@@ -601,8 +602,8 @@ public class AtkWrapper {
          }
         }
         if (role != null) {
-          if (newValue == javax.accessibility.AccessibleState.FOCUSED ||
-              newValue == javax.accessibility.AccessibleState.SELECTED) {
+          if (newValue == AccessibleState.FOCUSED ||
+              newValue == AccessibleState.SELECTED) {
             dispatchFocusEvent(o);
           }
         }
@@ -621,15 +622,15 @@ public class AtkWrapper {
           value = false;
         }
 
-        if(parent instanceof javax.swing.JComboBox && oldValue ==
-           javax.accessibility.AccessibleState.VISIBLE) {
+        if(parent instanceof JComboBox && oldValue ==
+           AccessibleState.VISIBLE) {
           objectStateChange(ac, AccessibleState.SHOWING, value);
         }
 
         objectStateChange(ac, state, value);
 
-        if (parent instanceof javax.swing.JComboBox && newValue ==
-            javax.accessibility.AccessibleState.VISIBLE && oldValue == null) {
+        if (parent instanceof JComboBox && newValue ==
+            AccessibleState.VISIBLE && oldValue == null) {
           objectStateChange(ac, AccessibleState.SHOWING, value);
         }
       }
@@ -650,28 +651,28 @@ public class AtkWrapper {
   public native static void loadAtkBridge();
   public native static void GC();
 
-  public native static void focusNotify(javax.accessibility.AccessibleContext ac);
+  public native static void focusNotify(AccessibleContext ac);
 
-  public native static void windowOpen(javax.accessibility.AccessibleContext ac,
+  public native static void windowOpen(AccessibleContext ac,
                                        boolean isToplevel);
-  public native static void windowClose(javax.accessibility.AccessibleContext ac,
+  public native static void windowClose(AccessibleContext ac,
                                         boolean isToplevel);
 
-  public native static void windowMinimize(javax.accessibility.AccessibleContext ac);
-  public native static void windowMaximize(javax.accessibility.AccessibleContext ac);
-  public native static void windowRestore(javax.accessibility.AccessibleContext ac);
-  public native static void windowActivate(javax.accessibility.AccessibleContext ac);
-  public native static void windowDeactivate(javax.accessibility.AccessibleContext ac);
-  public native static void windowStateChange(javax.accessibility.AccessibleContext ac);
+  public native static void windowMinimize(AccessibleContext ac);
+  public native static void windowMaximize(AccessibleContext ac);
+  public native static void windowRestore(AccessibleContext ac);
+  public native static void windowActivate(AccessibleContext ac);
+  public native static void windowDeactivate(AccessibleContext ac);
+  public native static void windowStateChange(AccessibleContext ac);
 
-  public native static void emitSignal(javax.accessibility.AccessibleContext ac, int id, Object[] args);
+  public native static void emitSignal(AccessibleContext ac, int id, Object[] args);
 
-  public native static void objectStateChange(javax.accessibility.AccessibleContext ac,
-                                              java.lang.Object state, boolean value);
+  public native static void objectStateChange(AccessibleContext ac,
+                                              Object state, boolean value);
 
-  public native static void componentAdded(javax.accessibility.AccessibleContext ac);
-  public native static void componentRemoved(javax.accessibility.AccessibleContext ac);
-  public native static void boundsChanged(javax.accessibility.AccessibleContext ac);
+  public native static void componentAdded(AccessibleContext ac);
+  public native static void componentRemoved(AccessibleContext ac);
+  public native static void boundsChanged(AccessibleContext ac);
   public native static boolean dispatchKeyEvent(AtkKeyEvent e);
 
   public static void printLog(String str) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]