B4J Library jToggleSwitch V1.0.0

DonManfred

Expert
Licensed User
jToggleSwitch
Author:
DonManfred (wrapper)
Version: 1
  • ToggleSwitch
    Events:
    • selectedChanged (selected As Boolean)
    Fields:
    • ba As BA
    Methods:
    • DesignerCreateView (base As ConcretePaneWrapper, label As LabelWrapper, args As Map)
    • Initialize (arg1 As String)
    • IsInitialized As Boolean
    • RemoveNodeFromParent
    • RequestFocus
    • SetAlphaAnimated (arg0 As Int, arg1 As Double)
    • SetLayoutAnimated (arg0 As Int, arg1 As Double, arg2 As Double, arg3 As Double, arg4 As Double)
    • SetSize (arg0 As Double, arg1 As Double)
    • Snapshot As ImageWrapper
    • Snapshot2 (arg0 As Paint) As ImageWrapper
    • isWrapText As Boolean
    Properties:
    • Alpha As Double
    • ContextMenu As ContextMenuWrapper
    • Enabled As Boolean
    • Height As Double [read only]
    • Id As String
    • LayoutX As Double [write only]
    • LayoutY As Double [write only]
    • Left As Double
    • MouseCursor As Cursor
    • PrefHeight As Double
    • PrefWidth As Double
    • Selected As Boolean
    • Style As String
    • StyleClass As String [write only]
    • StyleClasses As List [read only]
    • Tag As Object
    • Text As String
      Gets or sets the default label text value.
    • TooltipText As String
    • Top As Double
    • Visible As Boolean
    • Width As Double [read only]
    • WrapText As Boolean [write only]




If you want to donate for my work building the wrapper you can do it here:
 

Attachments

ShaneG30

Well-Known Member
Licensed User
Wow, thanks for the custom control. This is an excellent alternative to the boring CheckBox.
 

Siam

Active Member
Licensed User
Hi,

if i run the example i get the following messages in the Log window:

Program started.
Feb 25, 2016 12:16:58 PM com.sun.javafx.css.StyleConverterImpl getInstance
SEVERE: StyleConverterImpl : converter Class is null for : com.sun.javafx.scene.layout.region.CornerRadiiConverter
Feb 25, 2016 12:16:58 PM com.sun.javafx.css.StyleConverterImpl readBinary
SEVERE: could not deserialize com.sun.javafx.scene.layout.region.CornerRadiiConverter
could not deserialize com.sun.javafx.scene.layout.region.CornerRadiiConverter
greets
andy
 

ShaneG30

Well-Known Member
Licensed User
@DonManfred - I have a similar problem.

Program started.
Feb 25, 2016 8:43:14 AM com.sun.javafx.css.parser.CSSParser declaration
WARNING: CSS Error parsing '*{toggle-switch}: Expected COLON at [1,15]
 

Siam

Active Member
Licensed User
Hello,

i think there is something wrog :oops: i have placed one togglebutton with the designer to my screen and play a while with the button
after some klicks, is the button graphic no longer correct see the image

togglebutton.png

these messages i will get at starting my app:

Program started.
Feb 27, 2016 8:37:52 AM com.sun.javafx.css.parser.CSSParser declaration
WARNING: CSS Error parsing '*{toggle-switch}: Expected COLON at [1,15]
Feb 27, 2016 8:37:52 AM com.sun.javafx.css.StyleConverterImpl getInstance
SEVERE: StyleConverterImpl : converter Class is null for : com.sun.javafx.scene.layout.region.CornerRadiiConverter
Feb 27, 2016 8:37:52 AM com.sun.javafx.css.StyleConverterImpl readBinary
SEVERE: could not deserialize com.sun.javafx.scene.layout.region.CornerRadiiConverter
could not deserialize com.sun.javafx.scene.layout.region.CornerRadiiConverter
 
Last edited:

Suntzu

Member
Licensed User
Hi DonManfred, thank you for this library. Is it possible to put the text on the right side of the button?
 

Pitag

Member
Licensed User
Maybe a bug? when i generate the event with the Generate Members function in the visual designer, the new sub is named Toggleswitch1_checkedChanged(checked as boolean). But with this sub, when you change the state of the Toggleswitch no event is raised. In the example i found the correct name of the sub: Toggleswitch1_checkedChange(checked as boolean), without the d letter in the word Change.
In the first post the event is named 'selectedChanged(selected as boolean)
 

ThRuST

Well-Known Member
Licensed User
@DonManfred Very nice indeed, but can you please update it to work with Java v11 or later please? However I have not tested it with Java v11.
Someone please comment this if you're tried that combo.

Here's what I found
It works fine with Java JDK v1.8.0.191
However with Java JDK v9.0.4 it generates this in the IDE log

B4J v6.51 was used.
Waiting for debugger to connect...
Program started.
java.lang.NoClassDefFoundError: com/sun/javafx/css/converters/SizeConverter
at impl.org.controlsfx.skin.ToggleSwitchSkin.<clinit>(ToggleSwitchSkin.java:201)
at org.controlsfx.control.ToggleSwitch.createDefaultSkin(ToggleSwitch.java:150)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:897)
at javafx.controls/javafx.scene.control.Control.access$000(Control.java:83)
at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Control.java:89)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1419)
at javafx.graphics/javafx.scene.Parent.access$400(Parent.java:81)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:127)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:100)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1419)
at javafx.graphics/javafx.scene.Parent.access$400(Parent.java:81)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:127)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:100)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147)
at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9513)
at javafx.graphics/javafx.scene.Scene.doCSSPass(Scene.java:583)
at javafx.graphics/javafx.scene.Scene.preferredSize(Scene.java:1770)
at javafx.graphics/javafx.scene.Scene$2.preferredSize(Scene.java:394)
at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66)
at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1098)
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:1186)
at javafx.graphics/javafx.stage.Window.show(Window.java:1201)
at javafx.graphics/javafx.stage.Stage.show(Stage.java:276)
at anywheresoftware.b4j.objects.Form.Show(Form.java:205)
at b4j.example.main._appstart(main.java:81)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.start(main.java:38)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
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:175)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.css.converters.SizeConverter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 54 more
java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sun/javafx/css/converters/SizeConverter
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:94)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.start(main.java:38)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
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:175)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/css/converters/SizeConverter
at impl.org.controlsfx.skin.ToggleSwitchSkin.<clinit>(ToggleSwitchSkin.java:201)
at org.controlsfx.control.ToggleSwitch.createDefaultSkin(ToggleSwitch.java:150)
at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:897)
at javafx.controls/javafx.scene.control.Control.access$000(Control.java:83)
at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Control.java:89)
at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1419)
at javafx.graphics/javafx.scene.Parent.access$400(Parent.java:81)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:127)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:100)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147)
at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1419)
at javafx.graphics/javafx.scene.Parent.access$400(Parent.java:81)
at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:127)
at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:100)
at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147)
at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9513)
at javafx.graphics/javafx.scene.Scene.doCSSPass(Scene.java:583)
at javafx.graphics/javafx.scene.Scene.preferredSize(Scene.java:1770)
at javafx.graphics/javafx.scene.Scene$2.preferredSize(Scene.java:394)
at javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66)
at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1098)
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:1186)
at javafx.graphics/javafx.stage.Window.show(Window.java:1201)
at javafx.graphics/javafx.stage.Stage.show(Stage.java:276)
at anywheresoftware.b4j.objects.Form.Show(Form.java:205)
at b4j.example.main._appstart(main.java:81)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:625)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:168)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
... 12 more
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.css.converters.SizeConverter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 54 more
 
Last edited:

ThRuST

Well-Known Member
Licensed User
I see. But you might make a new version with stripped down methods and properties with only the most fundamental stuff in it.
For my use I would like just the basic switch mechanism with CSS support and check if it's set left or right, that will do it.
From what I have seen it's one of the most obvious controls so you might have something cooking for us :)
 
Top