B4J Question equivalent to invokeLater(new Runnable ??

Discussion in 'B4J Questions' started by Patent, Jul 14, 2019.

  1. Patent

    Patent Member Licensed User

    hi guys.

    whats the equivalent in B4J to this java code?:

    Code:
    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:
    Code:
    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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    As you are using CreateEventFromUI, the event is already invoked later. You don't need to do anything special.
     
    Patent likes this.
  3. Patent

    Patent Member Licensed User

    perfect.
    i was in hope for this! :)

    thanks Erel
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice