B4J Question Error :-( ---------- > could not create platform window

ivanomonti

Expert
Licensed User
Longtime User
I keep getting this error when I insert a javaobject or object that contains a drop down popup

code:
private Sub Grafico1_ContextMenu ' da inserire nel grafico1 ma non viene accettoto da javaobject
    
    Dim cm As ContextMenu
    cm.Initialize("")
    
    Dim mi As MenuItem
    mi.Initialize("hide line 1","mi")
    cm.MenuItems.Add(mi)
    
    Dim mi As MenuItem
    mi.Initialize("show line 1","mi")
    cm.MenuItems.Add(mi)
    
    Dim mi As MenuItem
    mi.Initialize("blink line 2","mi")
    cm.MenuItems.Add(mi)
    
    Dim mi As MenuItem
    mi.Initialize("reset zoom","mi")
    cm.MenuItems.Add(mi)
    
    Dim mi As MenuItem
    mi.Initialize("zoom +","mi")
    cm.MenuItems.Add(mi)
    
    Dim mi As MenuItem
    mi.Initialize("zoom -","mi")
    cm.MenuItems.Add(mi)
    
    Dim mi As MenuItem
    mi.Initialize("sound allarm","mi")
    cm.MenuItems.Add(mi)
    
    Button_blink_play.As(JavaObject).RunMethod("setContextMenu",Array(cm))
    
End Sub

Private Sub mi_Action
    Dim mi As MenuItem = Sender
    Log(mi.Text)

    Select Case mi.Text
        
        Case "hide line 1"
            grafico1.LineVisible1=False
        Case "show line 1"
            grafico1.LineVisible1=True
        Case "blink line 2"
            If grafico1.blink3 = False Then
                grafico1.blink3 = True
            Else
                grafico1.blink3 = False
            End If
        Case "reset zoom"
            
        Case "zoom +"
            grafico1.lzoom1_Click
        Case "zoom -"
            grafico1.lzoom2_Click
        Case "sound allarm"
            Button_sound_aler_Click
    End Select

End Sub




B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing

java.lang.RuntimeException: could not create platform window
    at javafx.graphics/com.sun.glass.ui.Window.<init>(Window.java:294)
    at javafx.graphics/com.sun.glass.ui.win.WinWindow.<init>(WinWindow.java:54)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.createWindow(WinApplication.java:219)
    at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.initPlatformWindow(WindowStage.java:201)
    at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.init(WindowStage.java:143)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.createTKPopupStage(QuantumToolkit.java:678)
    at javafx.graphics/javafx.stage.PopupWindow.doVisibleChanging(PopupWindow.java:514)
    at javafx.graphics/javafx.stage.PopupWindow$1.doVisibleChanging(PopupWindow.java:107)
    at javafx.graphics/com.sun.javafx.stage.PopupWindowHelper.visibleChangingImpl(PopupWindowHelper.java:57)
    at javafx.graphics/com.sun.javafx.stage.WindowHelper.visibleChanging(WindowHelper.java:73)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1064)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
    at javafx.graphics/javafx.stage.Window.show(Window.java:1189)
    at javafx.graphics/javafx.stage.PopupWindow.showImpl(PopupWindow.java:472)
    at javafx.graphics/javafx.stage.PopupWindow.show(PopupWindow.java:437)
    at javafx.controls/javafx.scene.control.ContextMenu.doShow(ContextMenu.java:321)
    at javafx.controls/javafx.scene.control.ContextMenu.show(ContextMenu.java:283)
    at javafx.controls/javafx.scene.control.Control.lambda$static$0(Control.java:199)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Scene.processMenuEvent(Scene.java:1925)
    at javafx.graphics/javafx.scene.Scene$ScenePeerListener.menuEvent(Scene.java:2640)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMenuEvent$3(GlassViewEventHandler.java:484)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMenuEvent$4(GlassViewEventHandler.java:464)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMenuEvent(GlassViewEventHandler.java:463)
    at javafx.graphics/com.sun.glass.ui.View.handleMenuEvent(View.java:564)
    at javafx.graphics/com.sun.glass.ui.View.notifyMenu(View.java:894)
    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)
java.lang.NullPointerException
    at javafx.base/com.sun.javafx.binding.ExpressionHelper.removeListener(ExpressionHelper.java:73)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.removeListener(ReadOnlyBooleanPropertyBase.java:61)
    at javafx.graphics/javafx.stage.PopupWindow.unbindOwnerFocusedProperty(PopupWindow.java:895)
    at javafx.graphics/javafx.stage.PopupWindow.doVisibleChanged(PopupWindow.java:542)
    at javafx.graphics/javafx.stage.PopupWindow$1.doVisibleChanged(PopupWindow.java:111)
    at javafx.graphics/com.sun.javafx.stage.PopupWindowHelper.visibleChangedImpl(PopupWindowHelper.java:63)
    at javafx.graphics/com.sun.javafx.stage.WindowHelper.visibleChanged(WindowHelper.java:77)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1147)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
    at javafx.graphics/javafx.stage.Window.hide(Window.java:1199)
    at javafx.graphics/javafx.stage.PopupWindow.hide(PopupWindow.java:486)
    at javafx.controls/javafx.scene.control.ContextMenu.hide(ContextMenu.java:295)
    at javafx.controls/javafx.scene.control.skin.ButtonSkin.lambda$new$4(ButtonSkin.java:111)
    at javafx.controls/com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
    at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:360)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
    at javafx.graphics/javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:8154)
    at javafx.graphics/javafx.scene.Node.setFocused(Node.java:8207)
    at javafx.graphics/javafx.scene.Scene$KeyHandler.setWindowFocused(Scene.java:4066)
    at javafx.graphics/javafx.scene.Scene$KeyHandler.lambda$new$0(Scene.java:4088)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:348)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setFocused(Window.java:674)
    at javafx.graphics/javafx.stage.Window$1.setFocused(Window.java:149)
    at javafx.graphics/com.sun.javafx.stage.WindowHelper.setFocused(WindowHelper.java:112)
    at javafx.graphics/com.sun.javafx.stage.WindowPeerListener.changedFocused(WindowPeerListener.java:64)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:126)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$4(GlassWindowEventHandler.java:176)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:174)
    at javafx.graphics/com.sun.glass.ui.Window.handleWindowEvent(Window.java:1351)
    at javafx.graphics/com.sun.glass.ui.Window.notifyFocus(Window.java:1330)
    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)
java.lang.RuntimeException: could not create platform window
    at javafx.graphics/com.sun.glass.ui.Window.<init>(Window.java:294)
    at javafx.graphics/com.sun.glass.ui.win.WinWindow.<init>(WinWindow.java:54)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.createWindow(WinApplication.java:219)
    at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.initPlatformWindow(WindowStage.java:201)
    at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.init(WindowStage.java:143)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.createTKPopupStage(QuantumToolkit.java:678)
    at javafx.graphics/javafx.stage.PopupWindow.doVisibleChanging(PopupWindow.java:514)
    at javafx.graphics/javafx.stage.PopupWindow$1.doVisibleChanging(PopupWindow.java:107)
    at javafx.graphics/com.sun.javafx.stage.PopupWindowHelper.visibleChangingImpl(PopupWindowHelper.java:57)
    at javafx.graphics/com.sun.javafx.stage.WindowHelper.visibleChanging(WindowHelper.java:73)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1064)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
    at javafx.graphics/javafx.stage.Window.show(Window.java:1189)
    at javafx.graphics/javafx.stage.PopupWindow.showImpl(PopupWindow.java:472)
    at javafx.graphics/javafx.stage.PopupWindow.show(PopupWindow.java:437)
    at javafx.controls/javafx.scene.control.ContextMenu.doShow(ContextMenu.java:321)
    at javafx.controls/javafx.scene.control.ContextMenu.show(ContextMenu.java:283)
    at javafx.controls/javafx.scene.control.Control.lambda$static$0(Control.java:199)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Scene.processMenuEvent(Scene.java:1925)
    at javafx.graphics/javafx.scene.Scene$ScenePeerListener.menuEvent(Scene.java:2640)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMenuEvent$3(GlassViewEventHandler.java:484)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMenuEvent$4(GlassViewEventHandler.java:464)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMenuEvent(GlassViewEventHandler.java:463)
    at javafx.graphics/com.sun.glass.ui.View.handleMenuEvent(View.java:564)
    at javafx.graphics/com.sun.glass.ui.View.notifyMenu(View.java:894)
    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)
java.lang.NullPointerException
    at javafx.base/com.sun.javafx.binding.ExpressionHelper.removeListener(ExpressionHelper.java:73)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.removeListener(ReadOnlyBooleanPropertyBase.java:61)
    at javafx.graphics/javafx.stage.PopupWindow.unbindOwnerFocusedProperty(PopupWindow.java:895)
    at javafx.graphics/javafx.stage.PopupWindow.doVisibleChanged(PopupWindow.java:542)
    at javafx.graphics/javafx.stage.PopupWindow$1.doVisibleChanged(PopupWindow.java:111)
    at javafx.graphics/com.sun.javafx.stage.PopupWindowHelper.visibleChangedImpl(PopupWindowHelper.java:63)
    at javafx.graphics/com.sun.javafx.stage.WindowHelper.visibleChanged(WindowHelper.java:77)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1147)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
    at javafx.graphics/javafx.stage.Window.hide(Window.java:1199)
    at javafx.graphics/javafx.stage.PopupWindow.hide(PopupWindow.java:486)
    at javafx.controls/javafx.scene.control.ContextMenu.hide(ContextMenu.java:295)
    at javafx.controls/javafx.scene.control.skin.ButtonSkin.lambda$new$4(ButtonSkin.java:111)
    at javafx.controls/com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
    at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:360)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
    at javafx.graphics/javafx.scene.Node$FocusedProperty.notifyListeners(Node.java:8154)
    at javafx.graphics/javafx.scene.Node.setFocused(Node.java:8207)
    at javafx.graphics/javafx.scene.Scene$KeyHandler.setWindowFocused(Scene.java:4066)
    at javafx.graphics/javafx.scene.Scene$KeyHandler.lambda$new$0(Scene.java:4088)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:348)
    at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanPropertyBase.fireValueChangedEvent(ReadOnlyBooleanPropertyBase.java:72)
    at javafx.base/javafx.beans.property.ReadOnlyBooleanWrapper.fireValueChangedEvent(ReadOnlyBooleanWrapper.java:103)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setFocused(Window.java:674)
    at javafx.graphics/javafx.stage.Window$1.setFocused(Window.java:149)
    at javafx.graphics/com.sun.javafx.stage.WindowHelper.setFocused(WindowHelper.java:112)
    at javafx.graphics/com.sun.javafx.stage.WindowPeerListener.changedFocused(WindowPeerListener.java:64)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:126)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$4(GlassWindowEventHandler.java:176)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:174)
    at javafx.graphics/com.sun.glass.ui.Window.handleWindowEvent(Window.java:1351)
    at javafx.graphics/com.sun.glass.ui.Window.notifyFocus(Window.java:1330)
    at javafx.graphics/com.sun.glass.ui.win.WinWindow._setVisible(Native Method)
    at javafx.graphics/com.sun.glass.ui.Window.setVisible(Window.java:684)
    at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.lambda$setVisible$2(WindowStage.java:533)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithRenderLock(QuantumToolkit.java:430)
    at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.setVisible(WindowStage.java:529)
    at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1124)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
    at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
    at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
    at javafx.graphics/javafx.stage.Window.hide(Window.java:1199)
    at javafx.graphics/com.sun.javafx.stage.WindowCloseRequestHandler.dispatchBubblingEvent(WindowCloseRequestHandler.java:45)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/com.sun.javafx.stage.WindowPeerListener.closing(WindowPeerListener.java:93)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:147)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$4(GlassWindowEventHandler.java:176)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:174)
    at javafx.graphics/com.sun.glass.ui.Window.handleWindowEvent(Window.java:1351)
    at javafx.graphics/com.sun.glass.ui.Window.notifyClose(Window.java:1251)
    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)
*** mainpage: B4XPage_Disappear [mainpage]
BaseWnd::Create(GlassWndClass-GlassWindowClass-3) error: 1158
BaseWnd::Create(GlassWndClass-GlassWindowClass-4) error: 1158
 

DonManfred

Expert
Licensed User
Longtime User
As far as i know you can not use any Swing-Components in B4X
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
...hmmm....

not sure... what is wrong... but here an example how it works to me... i think javafx :)

B4X:
    Private ContextMenu1 As ContextMenu
    Dim MenuText() As String
...

...

    ContextMenu1.Initialize("ContextMenu1")
    Dim MenuText() As String= Array As String("1st option","2nd option","3rd option")
    For i = 0 To MenuText.Length - 1
        Private TheMenuItem As MenuItem
        TheMenuItem.Initialize(MenuText(i),"cxm1")
        ContextMenu1.MenuItems.Add(TheMenuItem)
    Next
    AddEventHandler(others,"others")


Sub AddEventHandler(n As Node, EventName As String)
    'add an event handler and a ContextMenuEvent to the node which was passed
    Private joNode As JavaObject = n
    Private ev As Object = joNode.CreateEventFromUI("javafx.event.EventHandler",EventName,False)
    joNode.RunMethod("setOnContextMenuRequested",Array(ev))
End Sub


Private Sub others_MouseClicked (EventData As MouseEvent)
    Private joCM As JavaObject = ContextMenu1
    Private joED As JavaObject = EventData
    Private ScreenX As Double = joED.RunMethod("getScreenX", Null)
    Private ScreenY As Double = joED.RunMethod("getScreenY", Null)
    joCM.RunMethod("show",Array(others,ScreenX,ScreenY))
End Sub




Sub cxm1_Action
    'get the sender, menuitem clicked and do something with it
    Private meit As MenuItem = Sender
    Select Case meit.Text

            case "1st option"
            case "2nd option"
            case "3rd option"
    End Select
End Sub

ps: "others" can be a label for example
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Your code works fine for me ( had to fill in the missing bits )

B4X:
...
	Type fred(LineVisible1 As Boolean, blink3 As Boolean)
	Dim grafico1 As fred
	Private TextField1 As B4XView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
	MainForm = Form1
	MainForm.RootPane.LoadLayout("Layout1")
	MainForm.Show
	Grafico1_ContextMenu
End Sub

Sub Button1_Click
	xui.MsgboxAsync("Hello World!", "B4X")
End Sub

private Sub Grafico1_ContextMenu 
    
	Dim cm As ContextMenu
	cm.Initialize("")
    
	Dim mi As MenuItem
	mi.Initialize("hide line 1","mi")
	cm.MenuItems.Add(mi)
    
	Dim mi As MenuItem
	mi.Initialize("show line 1","mi")
	cm.MenuItems.Add(mi)
    
	Dim mi As MenuItem
	mi.Initialize("blink line 2","mi")
	cm.MenuItems.Add(mi)
    
	Dim mi As MenuItem
	mi.Initialize("reset zoom","mi")
	cm.MenuItems.Add(mi)
    
	Dim mi As MenuItem
	mi.Initialize("zoom +","mi")
	cm.MenuItems.Add(mi)
    
	Dim mi As MenuItem
	mi.Initialize("zoom -","mi")
	cm.MenuItems.Add(mi)
    
	Dim mi As MenuItem
	mi.Initialize("sound allarm","mi")
	cm.MenuItems.Add(mi)
	
	TextField1.As(JavaObject).RunMethod("setContextMenu",Array(cm))
    
End Sub

Sub mi_Action
	Dim mi As MenuItem = Sender

	Select Case mi.Text
        
		Case "hide line 1"
			grafico1.LineVisible1=False
		Case "show line 1"
			grafico1.LineVisible1=True
		Case "blink line 2"
			grafico1.blink3 = Not (grafico1.blink3)
			Log("blink3 " & grafico1.blink3)
		Case "reset zoom"
            
		Case "zoom +"
			grafico1lzoom1_Click
		Case "zoom -"
			grafico1lzoom2_Click
		Case "sound allarm"
			Button_sound_aler_Click
	End Select

End Sub
Sub grafico1lzoom1_Click
	Log("zoom +")
End Sub
Sub grafico1lzoom2_Click
	Log("zoom -")
End Sub
Sub Button_sound_aler_Click
	Log("beep")
End Sub
 
Upvote 0
Top