B4J Question Toast message lib for B4J without container

peacemaker

Expert
Licensed User
Longtime User
HI, All

Is it possible to show a toast message on the screen by B4J (like on Android), without depending on a form ? For server app.
 

peacemaker

Expert
Licensed User
Longtime User
jControlsFX9 v.1.51
OpenJDK 11:

ControlsUtils.ShowNotification does not work:
Waiting for debugger to connect...
Program started.
Error occurred on line: 61 (others)
java.lang.NullPointerException
    at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:367)
    at org.controlsfx.control.Notifications$NotificationPopupHandler.show(Notifications.java:329)
    at org.controlsfx.control.Notifications.show(Notifications.java:273)
    at org.controlsfx.control.Notifications.showInformation(Notifications.java:248)
    at anywheresoftware.b4j.objects.ControlsUtils.ShowNotification3(ControlsUtils.java:140)
    at anywheresoftware.b4j.objects.ControlsUtils.ShowNotification2(ControlsUtils.java:118)
    at anywheresoftware.b4j.objects.ControlsUtils.ShowNotification(ControlsUtils.java:112)
    at peacemaker.sc4.others._toast(others.java:55)
    at peacemaker.sc4.main._appstart(main.java:290)
    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:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    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:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:95)
    at peacemaker.sc4.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(Native Method)
    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:834)

ShowNotification2 and ShowNotification3 work, but it needs variant without the owner.


If to try the empty non-UI project - the error is so:
B4X:
Waiting for debugger to connect...
java.lang.NoClassDefFoundError: javafx/scene/Node
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
    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:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.ClassNotFoundException: javafx.scene.Node
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 13 more
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/Node
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:137)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.NoClassDefFoundError: javafx/scene/Node
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
    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:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
    ... 2 more
Caused by: java.lang.ClassNotFoundException: javafx.scene.Node
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 13 more

Project attached.
Looks like node-less toast is impossible...
 

Attachments

  • test_toast.zip
    761 bytes · Views: 84
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
need to create a UI app, without a form

Actually my app is such app - UI, but without form at start (with system tray icon, as you recommended). And error is of another kind, see above, 1st error.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Helped, thanks
 
Upvote 0
Top