Index: /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java
===================================================================
--- /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java	(revision 1685)
+++ /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDgenerateJacaretoReplay.java	(revision 1686)
@@ -47,4 +47,5 @@
 
     private int nextRef;
+    private JFCGUIElement currentFocus;
 
     /*
@@ -148,4 +149,9 @@
                     writeItemActionEvent(writer, structure, event);
                 }
+                /*
+                else if (event.getType() instanceof KeyboardFocusChange) {
+                    writeFocusChangeEvent(writer, structure, event);
+                }
+                */
             }
         }
@@ -261,4 +267,52 @@
     }
 
+    private void writeFocusChangeEvent(BufferedWriter writer,
+                                       ArrayList<String> structure,
+                                       Event event) throws IOException
+    {
+        KeyboardFocusChange info = (KeyboardFocusChange) event.getType();
+        JFCGUIElement target = (JFCGUIElement) event.getTarget();
+
+        if (currentFocus != null) {
+            // focus lost on old target
+            writeFocusEvent(writer, structure, info, currentFocus, 1005);
+            // focus gained on new target
+            writeFocusEvent(writer, structure, info, target, 1004);
+        }
+        else {
+            // TODO: it seems like Jacareto wants a window activation before
+            // the first focus event but that is not the case in autoquest,
+            // skip for now
+        }
+
+        currentFocus = target;
+    }
+
+    private void writeFocusEvent(BufferedWriter writer,
+                                 ArrayList<String> structure,
+                                 KeyboardFocusChange info,
+                                 JFCGUIElement target,
+                                 int jacId) throws IOException
+    {
+        //@formatter:off
+        writeLine(writer,
+            "<FocusEvent "
+            + "procTime=\"0\" "
+            + "duration=\"0\" "
+            + "source=\"" + target.getJacaretoHierarchy() + "\" "
+            + "class=\"" + target.getSpecification().getType() + "\" "
+            + "uuid=\"" + UUID.randomUUID() + "\" "
+            + "ID=\"" + jacId + "\" "
+            + "component=\"null\" "
+            + "root=\"" + target.getJacaretoRoot() + "\" "
+            + "xPos=\"0\" "
+            + "yPos=\"0\" "
+            + "width=\"0\" "
+            + "height=\"0\" "
+            + "isTemporary=\"false\" />" 
+        );
+        //@formatter:on
+    }
+
     private void writeMouseClickEvent(BufferedWriter writer,
                                       ArrayList<String> structure,
@@ -291,6 +345,6 @@
         writeLine(writer,
             "<MouseInfo "
-            + "xPosition=\"" + info.getX()+ "\" "
-            + "yPosition=\"" + info.getY()+ "\" "
+            + "xPosition=\"" + info.getX() + "\" "
+            + "yPosition=\"" + info.getY() + "\" "
             + "rootX=\"0\" "
             + "rootY=\"0\" "
