Login  Register

Re: Bug: Newt EDT invokeAndWait (from BrickFarmer)

Posted by BrickFarmer on Dec 14, 2010; 12:09pm
URL: https://forum.jogamp.org/Bug-Newt-EDT-invokeAndWait-from-BrickFarmer-tp2084832p2085100.html

you can replicate this in gears demo, replace the main method with the code below:



  public static void main(String[] args) {

        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {

                    final Frame frame = new Frame("Gear Demo");
                    GLCanvas canvas = new GLCanvas();

                    canvas.addGLEventListener(new Gears());
                    frame.add(canvas);
                    frame.setSize(300, 300);
                    final Animator animator = new Animator(canvas);
                    frame.addWindowListener(new WindowAdapter() {
                        public void windowClosing(WindowEvent e) {
                            // Run this on another thread than the AWT event queue to
                            // make sure the call to Animator.stop() completes before
                            // exiting
                            new Thread(new Runnable() {
                                public void run() {
                                    animator.stop();
                                    System.exit(0);
                                }
                            }).start();
                        }
                    });

                    frame.setVisible(true);
                    animator.start();

                }
            });
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

    }

I'm thinking the change to JAWTUtil (ca1e14eee25536a217d682c66f9ad07d5bdf642e) probably needs wrapping in:
if (!SwingUtilities.isEventDispatchThread()) {
...
}
but that's only based on looking at recent commits...

[edit] btw this is GLCanvas based, not newt