(Screen) javafx.stage.Screen@db765fab bounds:Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1080.0, width=1920.0, height=1080.0] visualBounds:Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1040.0, width=1920.0, height=1040.0] dpi:92.0 renderScale:1.0
(Screen) javafx.stage.Screen@21438938 bounds:Rectangle2D [minX = -1920.0, minY=7.0, maxX=0.0, maxY=1087.0, width=1920.0, height=1080.0] visualBounds:Rectangle2D [minX = -1920.0, minY=7.0, maxX=0.0, maxY=1047.0, width=1920.0, height=1040.0] dpi:92.0 renderScale:1.0
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
End Sub
Sub Button1_Click
For Each screen As Screen In fx.Screens
Log(screen & CRLF & "----------------------------" & CRLF)
Next
'xui.MsgboxAsync("Hello World!", "B4X")
End Sub
(Screen) javafx.stage.Screen@db765fab bounds:Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1080.0, width=1920.0, height=1080.0] visualBounds:Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1040.0, width=1920.0, height=1040.0] dpi:92.0 renderScale:1.0
----------------------------
(Screen) javafx.stage.Screen@21438938 bounds:Rectangle2D [minX = -1920.0, minY=7.0, maxX=0.0, maxY=1087.0, width=1920.0, height=1080.0] visualBounds:Rectangle2D [minX = -1920.0, minY=7.0, maxX=0.0, maxY=1047.0, width=1920.0, height=1040.0] dpi:92.0 renderScale:1.0
----------------------------
You shouldn't assume there's a primary monitor. Just pick the first one in the list and then let the user move the app window as they like. Perhaps just store what monitor they moved the app window to so you can open it there next time they launch the app. (For reference, that's pretty much how VMware Horizon Client does it.)And how to detect the primary monitor?
' If ignore borders are enabled in floating menu settings
If ToggleCheckbox4 = True Then
' Dynamically pause Floating menus on mouse X, Y pos
StoreState = ToggleMenu
For Each screen As Screen In fx.Screens
If currentMouseX <=50 Or currentMouseY <=50 Or currentMouseX >=ScreenWidth - 50 Or currentMouseY >=ScreenHeight - 100 Then
NativeHook_Static.Pause
Else
If StoreState = 1 Then
NativeHook_Static.ReStart
End If
End If
Next
End If
' Read mouse cursor position X & Y
Dim m() As Int = AWTRobot0.RobotMouseCurrentLocation
x = m(0)
y = m(1)
currentMouseX = m(0)
currentMouseY = m(1)
(Screen) javafx.stage.Screen@db765fab bounds:Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1080.0, width=1920.0, height=1080.0] visualBounds:Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1040.0, width=1920.0, height=1040.0] dpi:92.0 renderScale:1.0
----------------------------
(Screen) javafx.stage.Screen@21438938 bounds:Rectangle2D [minX = -1920.0, minY=7.0, maxX=0.0, maxY=1087.0, width=1920.0, height=1080.0] visualBounds:Rectangle2D [minX = -1920.0, minY=7.0, maxX=0.0, maxY=1047.0, width=1920.0, height=1040.0] dpi:92.0 renderScale:1.0
----------------------------
Type MyDisplay(Left As Double, Top As Double, Width As Double, Height As Double)
Private Desktop(10) As MyDisplay
Private cnt As int = 0
For Each o As JavaObject In fx.Screens
Dim bounds As JavaObject = o.RunMethodjo("getBounds",Null)' required
Dim minX As Double = bounds.RunMethod("getMinX",Null)'required
Dim minY As Double = bounds.RunMethod("getMinY",Null)' required
Dim width As Double = bounds.RunMethod("getWidth",Null)' required
Dim height As Double = bounds.RunMethod("getHeight",Null)'required
Log($"Screen is ${width} x ${height} pixels"$)' optional
Log($"minimum X: ${minX} minimum Y: ${minY}"$)' optional
Desktop(cnt).Left = minX ' required
Desktop(cnt).Top = minY ' required
Desktop(cnt).Width = width ' required
Desktop(cnt).Height = height ' required
cnt = cnt + 1 ' required
Next