Index: /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCDialog.java
===================================================================
--- /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCDialog.java	(revision 2043)
+++ /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCDialog.java	(revision 2044)
@@ -16,5 +16,4 @@
 
 import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame;
-import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView;
 
 /**
@@ -26,5 +25,5 @@
  * @author Patrick Harms
  */
-public class JFCDialog extends JFCGUIElement implements IFrame, IGUIView {
+public class JFCDialog extends JFCGUIElement implements IFrame {
 
     /**
@@ -60,11 +59,3 @@
     }
 
-    /* (non-Javadoc)
-     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView#isModal()
-     */
-    @Override
-    public boolean isModal() {
-        return true;
-    }
-
 }
Index: /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCFrame.java
===================================================================
--- /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCFrame.java	(revision 2043)
+++ /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCFrame.java	(revision 2044)
@@ -16,5 +16,4 @@
 
 import de.ugoe.cs.autoquest.eventcore.guimodel.IFrame;
-import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView;
 
 /**
@@ -26,5 +25,5 @@
  * @author Patrick Harms
  */
-public class JFCFrame extends JFCGUIElement implements IFrame, IGUIView {
+public class JFCFrame extends JFCGUIElement implements IFrame {
 
     /**
@@ -60,11 +59,3 @@
     }
 
-    /* (non-Javadoc)
-     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView#isModal()
-     */
-    @Override
-    public boolean isModal() {
-        return false;
-    }
-
 }
Index: /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java
===================================================================
--- /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java	(revision 2043)
+++ /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCGUIElement.java	(revision 2044)
@@ -39,4 +39,40 @@
     /**
      * <p>
+     * the default distance value for different applications
+     * </p>
+     */
+    protected static final double DISTANCE_DISTINCT_APPLICATION = 1.0;
+
+    /**
+     * <p>
+     * the default distance value for same application but different views, i.e., dialogs, frames,
+     * or tabbed panes
+     * </p>
+     */
+    protected static final double DISTANCE_SAME_APPLICATION = 0.75;
+
+    /**
+     * <p>
+     * the default distance value for same view but different panels
+     * </p>
+     */
+    protected static final double DISTANCE_SAME_VIEW = 0.5;
+
+    /**
+     * <p>
+     * the default distance value for same parent panel but different GUI elements 
+     * </p>
+     */
+    protected static final double DISTANCE_SAME_PANEL = 0.2;
+
+    /**
+     * <p>
+     * the default distance value for identical GUI elements
+     * </p>
+     */
+    protected static final double DISTANCE_NONE = 0.0;
+
+    /**
+     * <p>
      * Specification of the GUI Element
      * </p>
@@ -192,9 +228,11 @@
     @Override
     public IGUIView getView() {
-        IGUIElement element = this;
-        
-        while ((element != null) && (!(element instanceof IGUIView))) {
+        JFCGUIElement element = this;
+        
+        while ((element != null) && (!(element instanceof JFCFrame)) &&
+               (!(element instanceof JFCDialog)))
+        {
             if (!(element.getParent() instanceof JFCTabbedPane)) {
-                element = element.getParent();
+                element = (JFCGUIElement) element.getParent();
             }
             else {
@@ -204,5 +242,5 @@
         }
         
-        return (IGUIView) element;
+        return new JFCView(element);
     }
 
@@ -214,5 +252,85 @@
     @Override
     public double getDistanceTo(IGUIElement otherElement) {
-        throw new UnsupportedOperationException("not implemented yet");
+        if (otherElement instanceof JFCGUIElement) {
+            if (equals(otherElement)) {
+                return DISTANCE_NONE;
+            }
+            
+            if (!areInSameView(this, otherElement)) {
+                IGUIElement root1 = this;
+                
+                while (root1.getParent() != null) {
+                    root1 = root1.getParent();
+                }
+                
+                IGUIElement root2 = otherElement;
+                
+                while (root2.getParent() != null) {
+                    root2 = root2.getParent();
+                }
+                
+                if (!root1.equals(root2)) {
+                    return DISTANCE_DISTINCT_APPLICATION;
+                }
+                else {
+                    return DISTANCE_SAME_APPLICATION;
+                }
+            }
+            else {
+                // check if they have the same parent panel. If so, they are very close.
+                // If not, they may be structured completely differently
+                IGUIElement parentPanel1 = this;
+                
+                while (parentPanel1 != null) {
+                    if ((parentPanel1 instanceof JFCPanel) ||
+                        (parentPanel1 instanceof JFCFrame) ||
+                        (parentPanel1 instanceof JFCDialog) ||
+                        (parentPanel1 instanceof JFCCanvas) ||
+                        (parentPanel1 instanceof JFCMenu) ||
+                        (parentPanel1 instanceof JFCScrollPane) ||
+                        (parentPanel1 instanceof JFCSplitPane) ||
+                        (parentPanel1 instanceof JFCTabbedPane))
+                    {
+                        break;
+                    }
+                    else {
+                        parentPanel1 = parentPanel1.getParent();
+                    }
+                }
+                
+                IGUIElement parentPanel2 = otherElement;
+                
+                while (parentPanel2 != null) {
+                    if ((parentPanel2 instanceof JFCPanel) ||
+                        (parentPanel2 instanceof JFCFrame) ||
+                        (parentPanel2 instanceof JFCDialog) ||
+                        (parentPanel2 instanceof JFCCanvas) ||
+                        (parentPanel2 instanceof JFCMenu) ||
+                        (parentPanel2 instanceof JFCScrollPane) ||
+                        (parentPanel2 instanceof JFCSplitPane) ||
+                        (parentPanel2 instanceof JFCTabbedPane))
+                    {
+                        break;
+                    }
+                    else {
+                        parentPanel2 = parentPanel2.getParent();
+                    }
+                }
+                
+                // a check for the identity of the objects is sufficient. That they resist on the
+                // same document was checked beforehand. So even a condense of the GUI model should
+                // not cause an invalid result here.
+                if ((parentPanel1 == parentPanel2) ||
+                    ((parentPanel1 != null) && (parentPanel1.equals(parentPanel2))))
+                {
+                    return DISTANCE_SAME_PANEL;
+                }
+                else {
+                    return DISTANCE_SAME_VIEW;
+                }
+            }
+        }
+        
+        return DISTANCE_DISTINCT_APPLICATION;
     }
 
@@ -228,3 +346,31 @@
     }
 
+    /**
+     * <p>
+     * convenience method to check if two GUI elements are in the same view. In contrast to other
+     * technologies, JFC GUI views may have other views as children. Hence, it is not sufficient to
+     * check, if the direct parent views are identical.
+     * </p>
+     */
+    private boolean areInSameView(IGUIElement guiElement1, IGUIElement guiElement2) {
+        IGUIView view1 = guiElement1.getView();
+        IGUIElement other = guiElement2;
+        
+        while (other != null) {
+            if (view1.equals(other.getView())) {
+                return true;
+            }
+            
+            other = other.getParent();
+        }
+        
+        // the parent views of the other gui element are checked. But not the ones of this. Hence,
+        // check also them.
+        if ((view1 instanceof JFCView) && (((JFCView) view1).getParent() != null)) {
+            return areInSameView(((JFCView) view1).getParent(), guiElement2);
+        }
+        else {
+            return false;
+        }
+    }
 }
Index: /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCView.java
===================================================================
--- /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCView.java	(revision 2044)
+++ /trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/guimodel/JFCView.java	(revision 2044)
@@ -0,0 +1,114 @@
+//   Copyright 2012 Georg-August-Universität Göttingen, Germany
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+
+package de.ugoe.cs.autoquest.plugin.jfc.guimodel;
+
+import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
+import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
+import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView;
+
+/**
+ * <p>
+ * A wrapper for JFC GUI elements which need to be considered a view. Usually, these are frames,
+ * dialogs, and child panels of tabbed panes. The class delegates calls to the wrapped GUI element.
+ * </p>
+ * 
+ * @author Patrick Harms
+ */
+public class JFCView implements IGUIView {
+
+    /**  */
+    private static final long serialVersionUID = 1L;
+    
+    /** */
+    private JFCGUIElement delegate;
+    
+    /**
+     * The default constructor taking the GUI element being the view as parameter
+     */
+    JFCView(JFCGUIElement delegate) {
+        this.delegate = delegate;
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView#isModal()
+     */
+    @Override
+    public boolean isModal() {
+        return delegate instanceof JFCDialog;
+    }
+
+    /**
+     * @return
+     * @see de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement#getPlatform()
+     */
+    public String getPlatform() {
+        return delegate.getPlatform();
+    }
+
+    /**
+     * @return
+     * @see de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement#getParent()
+     */
+    public IGUIElement getParent() {
+        return delegate.getParent();
+    }
+
+    /**
+     * @return
+     * @see de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement#getGUIModel()
+     */
+    public GUIModel getGUIModel() {
+        return delegate.getGUIModel();
+    }
+
+    /**
+     * @return
+     * @see de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement#getName()
+     */
+    public String getName() {
+        return delegate.getName();
+    }
+
+    /**
+     * @param other
+     * @return
+     * @see de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement#equals(java.lang.Object)
+     */
+    public final boolean equals(Object other) {
+        if (other instanceof JFCView) {
+            return delegate.equals(((JFCView) other).delegate);
+        }
+        else {
+            return false;
+        }
+    }
+
+    /**
+     * @return
+     * @see de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement#hashCode()
+     */
+    public final int hashCode() {
+        return delegate.hashCode();
+    }
+
+    /**
+     * @return
+     * @see de.ugoe.cs.autoquest.plugin.jfc.guimodel.JFCGUIElement#toString()
+     */
+    public String toString() {
+        return delegate.toString();
+    }
+
+}
