Hi everyone,
I need help.
I'm trying to implement a context menu in a desktop app (B4J - B4XPages) that can be accessed by right-clicking on a panel or root view.
Is this possible?
Currently, I can only create a simple context menu that is attached to a button or label, but when I try to attach it to a panel or form, it gives me an error... see the highlighted part... Is this even possible to do?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Error:
Error is in line: joTable.RunMethod("setContextMenu", Array(ctxMenu)
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I need help.
I'm trying to implement a context menu in a desktop app (B4J - B4XPages) that can be accessed by right-clicking on a panel or root view.
Is this possible?
Currently, I can only create a simple context menu that is attached to a button or label, but when I try to attach it to a panel or form, it gives me an error... see the highlighted part... Is this even possible to do?
			
				Example code:
			
		
		
		    Dim ctxMenu As ContextMenu
    ctxMenu.Initialize("")
    Dim MT() As String = Array As String("MI1","MI2","MI3")
    For i = 0 To MT.Length - 1
        Dim Mi As MenuItem
        Mi.Initialize(MT(i),"ctxm")
        ctxMenu.MenuItems.Add(Mi)
    Next
    ' this line works and context menu is bound with button
     ' Dim v As B4XView = btnIzpisi
    ' v.As(JavaObject).RunMethod("setContextMenu",Array(ctxMenu))
  
    ' I want to bound context menu with pane or root.view or b4xtable
   ' HERE IS A ERROR - how can I bound context menu with f.e. b4xTable?! or panel (Pane)
    Dim joTable As JavaObject = Root.GetView(0)
    joTable.RunMethod("setContextMenu", Array(ctxMenu))Error:
Error is in line: joTable.RunMethod("setContextMenu", Array(ctxMenu)
			
				Error:
			
		
		
		WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Error occurred on line: 88 (pgListaZaloga)
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:486)
    at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:876)
    at b4j.example.b4xpagesmanager._showpage(b4xpagesmanager.java:355)
    at b4j.example.b4xpagesmanager._addpage(b4xpagesmanager.java:176)
    at b4j.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:190)
    at b4j.example.b4xpagesmanager._initialize(b4xpagesmanager.java:126)
    at b4j.example.main._appstart(main.java:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:134)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81)
    ... 35 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:115)
    ... 36 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:486)
    at b4j.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:876)
    at b4j.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:193)
    at b4j.example.b4xpages._addpageandcreate(b4xpages.java:82)
    at b4j.example.b4xmainpage._b4xpage_created(b4xmainpage.java:207)
    ... 41 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:134)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:81)
    ... 50 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:115)
    ... 51 more
Caused by: java.lang.RuntimeException: Method: setContextMenu not found in: anywheresoftware.b4j.objects.PaneWrapper$ConcretePaneWrapper$NonResizePane
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at b4j.example.pglistazaloga._initpage(pglistazaloga.java:224)
    at b4j.example.pglistazaloga._b4xpage_created(pglistazaloga.java:102)
    ... 56 more
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
	
								
							
							 
				 
 
		 
 
		 
 
		
 
 
		