Max Still Hangs with SwingUtilities.invokeLater...

Léopold Frey's icon

Hi,

I've found another problem, not sure it's a bug.
I'm often working with mxjs containing Jframes.
When the object is deleted, I want the Jframe to be destroyed.
I use the notifyDeleted method to do this.
It works, if I delete the box manually or via scripting, but when the Jframe
is open and I edit the mxj box (for example to add a argument), max hangs
though I use the SwingUtilities.invokeLater.... method.
Am I doing something wrong ?

See example below.

DelTest.java

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import com.cycling74.max.MaxObject;

public class DelTest extends MaxObject
{
JFrame frame;

public DelTest()
{
frame = new JFrame("test");
frame.setSize(200,200);
frame.setLocationRelativeTo(null);
}

public void notifyDeleted()
{
post("deleting...");
close();
}

public void open()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
frame.setVisible(true);
}
});
}

public void close()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
frame.setVisible(false);
}
});
}

public void dblclick()
{
open();
}
}

Max Patch
Copy patch and select New From Clipboard in Max.