B4J Question [Solved, it does work] Add CustomViews in code doesn't work

klaus

Expert
Licensed User
EDIT:
My bad, see post#5.
Attached the correct routine B4J_KCButtonsDemoNew.
KCButtonsDemo is the wrong one.

I am writing a CustomView class.
Adding the CustomView in the Designer works perfectly, but trying to add them in code doesn't work.
I get this error:
B4J version: 4.20 (1)
Parsing code. (0.01s)
Compiling code. (2.33s)
Compiling layouts code. (0.00s)
Compiling generated Java code. Error
B4J line: 27
MainForm.RootPane.AddNode(btnTest3, 190, 200, 60,
javac 1.8.0_92
src\b4j\example\main.java:98: error: incompatible types: kcbutton cannot be converted to Node
_mainform.getRootPane().AddNode((javafx.scene.Node)(_btntest3),190,200,60,40);
when I try to add the CustomView in this line:
MainForm.RootPane.AddNode(btnTest3, 190, 200, 60, 40)

Is there a technical reason why it doesn't work ?
 

Attachments

Last edited:

klaus

Expert
Licensed User
This means that the principle in B4J is different than in B4A.
I made a same CustomView class in B4A where I can add the CustomView in the code.
The goal of these CustomViews is to have the same code in both B4A and B4J and probably B4i.
Attached the B4A Class.
 

Attachments

klaus

Expert
Licensed User
Hi Erel,
Sorry for having bothered you !
I did the same approch like in B4A and had the AddToParent routine in the B4J Class, but I didn't use it !?
Don't know why i tryed to add the CustomView like a 'standard' Node. This approch doesn't work in B4A either.
Sometimes I can't see the forest for the trees and need the eyes of someone else.
 
Last edited:
Top