Explorar el Código

removed Exception in thread 'AWT-EventQueue-0'

Kolja Strohm hace 6 años
padre
commit
3847267d08
Se han modificado 1 ficheros con 13 adiciones y 6 borrados
  1. 13 6
      src/animation/PseudoCodeNode.java

+ 13 - 6
src/animation/PseudoCodeNode.java

@@ -1,6 +1,7 @@
 package animation;
 
 import javax.swing.JTree;
+import javax.swing.SwingUtilities;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.MutableTreeNode;
 import javax.swing.tree.TreePath;
@@ -162,18 +163,24 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         {
             if( controller == null || controller.getStepOption() != 1 || breakPoint )
             {
-                synchronized( tree ) { // TODO figure out if this solves Exception in thread "AWT-EventQueue-0"
-                    expandToRoot();
-                }
+                SwingUtilities.invokeLater( new Runnable() {
+                    @Override
+                    public void run() {
+                        expandToRoot();
+                    }
+                });
             }
         }
         else
         {
             if( controller == null || controller.getStepOption() != 1 )
             {
-                synchronized( tree ) {
-                    tree.collapsePath( new TreePath( this.getPath() ) );
-                }
+                SwingUtilities.invokeLater( new Runnable() {
+                    @Override
+                    public void run() {
+                        tree.collapsePath( new TreePath( getPath() ) );
+                    }
+                });
             }
         }
         if( breakPoint && selected )