B4J Question Deal Events with a Swing JFrame.......

Patent

Member
Licensed User
Longtime User
Dear community,

i have to work with a swing JFrame (because an old ext.Lib. needs one...:().
Please see the example, frameevent is working,
frameevent2 not.
No firering.
Any ideas?

thnks a lot
patent
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
   
    Dim joJFrame As JavaObject
   
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
   
    joJFrame.Initializenewinstance("javax.swing.JFrame",Null)       
       
    joJFrame.RunMethod("setTitle",Array("JFrame"))
    joJFrame.RunMethod("setSize",Array(300,300))
   
   
    Dim frame As JavaObject=joJFrame
    Dim listener As JavaObject=joJframe.CreateEvent("java.awt.event.WindowListener","frameevent",False)
    frame.RunMethod("addWindowListener",Array As Object(listener))
   
    
    Dim listener2 As JavaObject=frame.CreateEvent("java.awt.event.MouseListener","frameevent2",False)
    frame.RunMethod("addMouseListener",Array As Object(listener2))
   
    joJFrame.RunMethod("addNotify",Null)               
    joJFrame.RunMethod("setVisible",Array(True))
End Sub


Sub frameevent_Event (MethName As String,Args() As Object) As Object
    Log(MethName)
End Sub


Sub frameevent2_MousePressed (e As MouseEvent)
    Log(e)
End Sub
 

Patent

Member
Licensed User
Longtime User
thanks erel, you give me the right lever. :)

this works:

B4X:
Sub  FrameEvent2_Event  (MethName As String, Args() As Object) As Object
    Log(MethName)
End Sub
 
Upvote 0
Top