B4J Library [Class] jNumberSpinner

Discussion in 'B4J Libraries & Classes' started by stevel05, Feb 28, 2015.

  1. stevel05

    stevel05 Expert Licensed User

    I have been looking for a numberspinner that allows Doubles as well as Integers to port for B4j but haven't been able to find one that did exactly what I wanted, so I decided I would write one, and here it is.

    It uses NumberFormat2 to display the output and therefore has it's options. Although if you don't specify Minimum Integers or Grouping then 0 and False are assumed.

    The spinner responds to Clicks on the Spinners arrows, and the Keyboard Up and Down Arrows.

    The available methods are:

    Steve Laming
    Version: 1

    • Methods:

      AsNode As Node
      Get the AnchorPane that holds the NumberSpinner

      Grouping As Boolean
      Set whether grouping should be displayed

      Increment As Double
      Get / set the Increment

      Initialize(Module As Object, EventName As String, MinimumIntegers As Int, MaximumFractions As Int, Increment As Double) As String
      Initializes the object and set's the callback eventname and minimum required options.

      IsInitialized As Boolean
      Get the Initialized state of this Object

      Layout(Left As Double, Top As Double, Width As Double, Height As Double) As String - [Write Only]
      Set the Layout of the AnchorPane

      Left As Double
      Get/Set the AnchorPane Left value

      MaxFractions As Int
      Get / Set the maximum number of decimal places to display

      MaxValue As Double
      Get / Set the Maximum values

      MinFractions As Int
      Get / Set the minimum number of decimal places to display

      MinIntegers As Int
      Get / Set the minimum number of Integers to display

      MinValue As Double
      Get / Set the Minimum values

      PrefHeight As Double
      Get/Set the AnchorPane PrefHeight value

      PrefWidth As Double
      Get/Set the AnchorPane PrefWidth value

      Top As Double
      Get/Set the AnchorPane Top value

      Value As Double
      Get / Set the current Value. Should be between MinVal and MaxVal inclusive (if set)

    Provided callbacks are:

    {EventName}_ValueChanged(Val As Double,UserChanged As Boolean)
    - Called when a value is changed
    {EventName}_EntryReleased(Val As Double)
    - Called when the Mouse Button or Up or Down arrow Keys are released.

    The ENumClass code is also in the project.

    Depends on:
    javaobject, jenumclass

    i hope you find it useful.

    Attached Files:

    Last edited: Mar 6, 2015
    jcohedman, giga and Erel like this.
  2. Azam Rafique

    Azam Rafique New Member

    I am trying to use this class, and creating multiple Number Spinners using for-loop, when I change value of any Number Spinner, it calls a sub "Sub txt_value_ValueChanged", but when I use

    Dim send as Node
    Error is:
    numberspinner._setvalue (java line: 523)
    java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: b4j.example.numberspinner cannot be cast to javafx.scene.Node
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:456)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:425)
    at b4j.example.numberspinner._setvalue(numberspinner.java:523)

    how can I do this?
  3. Erel

    Erel Administrator Staff Member Licensed User

    It is not a node. send type should be NumberSpinner.
    Azam Rafique likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice