B4J Question equivalent to invokeLater(new Runnable ??

Patent

Member
Licensed User
Longtime User
hi guys.

whats the equivalent in B4J to this java code?:

B4X:
x.y.addEventListener(new EventAdapter() {
    @Override
public void error(someXYobject) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        JOptionPane.showMessageDialog(
                            frame,
                            "Failed to do something",
                            "Error",
                            JOptionPane.ERROR_MESSAGE
                        );
                        closeWindow();
                    }
                });
}

in B4J i am doing that:
B4X:
Dim myListener As Object=someObject.CreateEventFromUI("x.y.interface","myEvents",False)
someObject.RunMethod("addListener",Array As Object(myListener))


Sub myEvents_Event(MethodName As String,Args() As Object)
  Select MethodName
        Case "error"   
        'show dialog
  End Select
End Sub


Question is:
Do i get the right ....invokeLater(new Runnable() {.....
behaviour to safely call methods in swing classes from my Callback Sub?
Same for JavaFX?

thanks
 
Top