B4J Question [SOLVED] B4J Resizer for Statusbar

mfstuart

Active Member
Licensed User
Hi all,
Is there a B4J object that is like the .NET Statusbar resizer that is in the right most position of the statusbar?
When the user moves the mouse pointer over the object, which are a bunch of dots, the pointer changes to a NW-SE arrow image, which allows the user to then resize the form.

If there is a "work-around" object/view for this, can someone please elaborate?

Thanx,
Mark Stuart
 

mfstuart

Active Member
Licensed User
Yes, it is to resize the form.
It's easier to "grab/drag" something that is in a bigger area than the side frames of the form.

If you are familiar with the Visual Studio IDE, it has a grabber area in the bottom right and on the statusbar.
Without this, I'm having to put the mouse in the exact position on the form frame for resizing. Frustrating for me.
Having the grabber area makes a better user experience.

EDIT: so is it possible to add a resizer object to the Statusbar?

Thanx Erel,
Mark Stuart
 

Erel

Administrator
Staff member
Licensed User
I wouldn't use the StatusBar control. Simpler to use a regular pane anchored to the bottom and sides.

Put an ImageView with the resize image at the bottom right corner. It should be anchored to the bottom and to the right.

Set its cursor and set pick at bounds to true:
B4X:
imgResize.PickOnBounds = True
imgResize.MouseCursor = jo.InitializeStatic("javafx.scene.Cursor").GetField("SE_RESIZE")
B4X:
'resize code
Sub imgResize_MouseDragged (EventData As MouseEvent)
   Dim jo As JavaObject = EventData
   Dim ScreenX As Double = jo.RunMethod("getScreenX", Null)
   Dim ScreenY As Double = jo.RunMethod("getScreenY", Null)
   MainForm.WindowWidth = ScreenX - MainForm.WindowLeft
   MainForm.WindowHeight = ScreenY - MainForm.WindowTop
End Sub
 

mfstuart

Active Member
Licensed User
Hi,
I put your code into my Code Module as such:
B4X:
Sub Process_Globals
   Private imgResize As ImageView
End Sub

Sub imgResize_MouseDragged (EventData As MouseEvent)
    Dim jo As JavaObject = EventData
    'wasn't sure where to put the next 2 lines, so put them here
    'if not here, where should they be placed?
    imgResize.PickOnBounds = True
    imgResize.MouseCursor = jo.InitializeStatic("javafx.scene.Cursor").GetField("SE_RESIZE")
   
    Dim ScreenX As Double = jo.RunMethod("getScreenX", Null)    ' errors on this line
    Dim ScreenY As Double = jo.RunMethod("getScreenY", Null)
    frm.WindowWidth = ScreenX - frm.WindowLeft
    frm.WindowHeight = ScreenY - frm.WindowTop
End Sub
But get this error when dragging the image:
java.lang.RuntimeException: Method: getScreenX not found in: javafx.scene.Cursor
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)

I have the following libraries checked:
JavaObject
jControlsFX
jCore
jFX
jShell
jSQL

How to resolve?

Thanx,
Mark Stuart
 

mfstuart

Active Member
Licensed User
I'm not sure I can put them there as the Main Code Module is not the "Main" form.
MenuForm Code Module, is the "Main" form and is called from Login after a successful user login validation.

B4X:
#Region Project Attributes 
    #MainFormWidth: 1500
    #MainFormHeight: 800
    #AdditionalJar: jtds-1.3.1.jar
#End Region

Sub Process_Globals
    Private fx As JFX
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    DBManager.DBConnect
    'Login is a Code Module and is called here to allow the user to login to the app
    Login.Show
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
I'll have a go at putting the jo JavaObject and code in the MenuForm and see how it goes.

Thanx,
Mark Stuart
 

mfstuart

Active Member
Licensed User
Can't resolve the error:
B4X:
Dim ScreenX As Double = jo.RunMethod("getScreenX", Null)    ' errors on this line
Error message:
java.lang.RuntimeException: Method: getScreenX not found in: javafx.scene.Cursor
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
 

mfstuart

Active Member
Licensed User
Kiffi,
Downloaded your ResizeTest app and it worked perfectly.
The important part about defining how this works, is in where and how the Dim jo objects are declared, which was missing from Erel's #4 explanation, or didn't understand it.

Now I have my form resizing as expected.

Thank you,
Mark Stuart
 
Top