B4J Question Display Taskbar Message

GMan

Well-Known Member
Licensed User
Trying this, but did not work (with jSystemTray lib):

B4X:
       Private icon1 As SystemTray

       Dim jo As JavaObject = icon1
        jo.RunMethod("displayMessage",Array As Object("Success", "Changes pushed successfully", "INFO"))
 

DonManfred

Expert
Licensed User
Trying this, but did not work (with jSystemTray lib):
Sure. Why it should work like this? I dont see you initializing the SystemTray
Try
B4X:
icon1.Initialize
in app start
 
Upvote 0

GMan

Well-Known Member
Licensed User
You're rigth, but with this:

B4X:
Private icon1 as SystemTray
icon1.Initialize
    
    Dim jo As JavaObject = icon1
    jo.RunMethod("displayMessage",Array As Object("Phoenix Creator", "Starting...", "NONE"))

it causes this message in the log:

B4X:
main$ResumableSub_AppStart.resume (java line: 184)
java.lang.RuntimeException: Method: displayMessage not found in: anywheresoftware.b4j.objects.SystemTrayWrapper
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at phoenix.creator.main$ResumableSub_AppStart.resume(main.java:184)
    at phoenix.creator.main._appstart(main.java:150)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at phoenix.creator.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
 
Upvote 0

DonManfred

Expert
Licensed User
The b4j SystemTray Object does not have a method displayMessage.
Maybe SystemTray is just a small/basic Wrapper around java.awt.SystemTray. It has Methods for an Icon...

You maybe need to get the property "st" from the SystemTray Object first. This is the awt.SystemTray. Maybe using replector.
 
Upvote 0

DonManfred

Expert
Licensed User
B4X:
    Dim jo As JavaObject = systray ' systray is my Icon1
    jo = jo.GetFieldJO("st")
    Log(jo)
prints this to the log
(SystemTray) java.awt.SystemTray@5064f8fa
You now can try to call the Method you mentioned. Not sure wheter it works but at least you are now accessing the correct Object.
 
Upvote 0

tchart

Well-Known Member
Licensed User
This is my initilaize funtion, maybe its failing becuase you didnt specify an image for the icon?

B4X:
Private tray As SystemTray 'Process_Globals
Private icon1 As TrayIcon 'Process_Globals
Private LogoImage As Image 'Process_Globals

    LogoImage = fx.LoadImage(File.DirAssets, "favicon.png")

    tray.Initialize
    Dim MenuItems() As String = Array As String("Push Changes", "-", "Exit")
    icon1.Initialize("icon1", LogoImage, MenuItems)
    icon1.ToolTip = "Changes in queue: " & GetChangeCount
    tray.AddTrayIcon(icon1)
 
Upvote 0
Top