B4J Question Spinner Control - Issue

DMW

Member
Licensed User
Longtime User
Season greeting to everyone,

I have a spinner control that I like to customize in code. In a simple example:

B4X:
Sub Process_Globals
 Private fx As JFX
 Private MainForm As Form
 Private Spinner1 As Spinner
End Sub

Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 MainForm.RootPane.LoadLayout("Spinner") 'Load the layout file.
 Config_Spinner
 MainForm.Show 
End Sub

Sub Config_Spinner()
 Dim dbMin As Double = 1
 Dim dbMax As Double =500
 Dim dbSteps As Double = 1
 Dim dbInitial As Double = 1
 
 Spinner1.SetNumericItems(dbMin,dbMax,dbSteps,dbInitial)
 'Spinner1.SetNumericItems(1,500,1,1)
End Sub
When running the code it bombs out and the following error message is received:

B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 25 (Main)
java.lang.NullPointerException
  at com.sun.javafx.binding.ExpressionHelper.removeListener(ExpressionHelper.java:74)
  at javafx.beans.property.ObjectPropertyBase.removeListener(ObjectPropertyBase.java:92)
  at anywheresoftware.b4j.objects.SpinnerWrapper.removeListener(SpinnerWrapper.java:77)
  at anywheresoftware.b4j.objects.SpinnerWrapper.SetNumericItems(SpinnerWrapper.java:91)
  at b4j.example.main._config_spinner(main.java:107)
  at b4j.example.main._appstart(main.java:75)
  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:498)
  at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
  at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
  at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
  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:498)
  at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
  at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
  at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
  at b4j.example.main.start(main.java:38)
  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)
  at java.lang.Thread.run(Thread.java:745)

The same error code is received when using numeric (see code above).

Apparently there is something that I miss...

TIA,
Dennis
 

stevel05

Expert
Licensed User
Longtime User
Is the spinner named Spinner1 in the layout file?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Ignore that question, I've looked a bit deeper and it works if you add a ValueChanged event sub.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
  
    Dim SP As Spinner
    SP.Initialize("SP")
    MainForm.RootPane.AddNode(SP,100,100,100,50)
'    SP.SetListItems(Array As Double(1,2,3,4,5,6,7,8,9))
    SP.SetNumericItems(1,500,1,250)
  

End Sub

Sub SP_ValueChanged (Value As Object)
  
End Sub

Not quite the same behaviour as other Nodes, perhaps one for @Erel to look into.
 
Upvote 0
Top