jmon Well-Known Member Licensed User Longtime User Jan 22, 2016 #1 Hi, I think it would be very convenient to have a .RunMethod method for every node. So we would need to create new variables as JavaObject when running external methods. Current: Code: Copy Dim l As Label l.Initialize("") l.Text = "Blah" Dim lJo As JavaObject = l lJo.RunMethod("setRotate", Array(90.0)) Suggested: Code: Copy Dim l As Label l.Initialize("") l.Text = "Blah" l.RunMethod("setRotate", Array(90.0)) Or: Code: Copy Dim l As Label l.Initialize("") l.Text = "Blah" l.asJo.RunMethod("setRotate", Array(90.0)) I currently use the asJo snippet from @Daestrum (https://www.b4x.com/android/forum/threads/javaobjects-the-easy-way.45121/), which is very good, but I found that this new proposition would be a great addition. Thank you Jmon.
Hi, I think it would be very convenient to have a .RunMethod method for every node. So we would need to create new variables as JavaObject when running external methods. Current: Code: Copy Dim l As Label l.Initialize("") l.Text = "Blah" Dim lJo As JavaObject = l lJo.RunMethod("setRotate", Array(90.0)) Suggested: Code: Copy Dim l As Label l.Initialize("") l.Text = "Blah" l.RunMethod("setRotate", Array(90.0)) Or: Code: Copy Dim l As Label l.Initialize("") l.Text = "Blah" l.asJo.RunMethod("setRotate", Array(90.0)) I currently use the asJo snippet from @Daestrum (https://www.b4x.com/android/forum/threads/javaobjects-the-easy-way.45121/), which is very good, but I found that this new proposition would be a great addition. Thank you Jmon.
Erel B4X founder Staff member Licensed User Longtime User Jan 22, 2016 #2 Are there any other common methods such as setRotate that you are using? You can create this sub: Code: Copy Sub SetRotate(n As Node, Degrees As Double) Dim jo As JavaObject = n jo.RunMethod("setRotate", Array(Degrees)) End Sub Code: Copy SetRotate(label1, 45) SetRotate(label2, 90)
Are there any other common methods such as setRotate that you are using? You can create this sub: Code: Copy Sub SetRotate(n As Node, Degrees As Double) Dim jo As JavaObject = n jo.RunMethod("setRotate", Array(Degrees)) End Sub Code: Copy SetRotate(label1, 45) SetRotate(label2, 90)
jmon Well-Known Member Licensed User Longtime User Jan 22, 2016 #3 Thanks I was thinking about a general way of calling any Javafx method, like setPrefWidth, setMinWidth, setGraphic etc... that doesn't exist in B4J At the moment I use the asJo method by daestrum, which I find convenient enough. This idea I propose is just to make the code simpler and cleaner, nothing more
Thanks I was thinking about a general way of calling any Javafx method, like setPrefWidth, setMinWidth, setGraphic etc... that doesn't exist in B4J At the moment I use the asJo method by daestrum, which I find convenient enough. This idea I propose is just to make the code simpler and cleaner, nothing more
Daestrum Expert Licensed User Longtime User Jan 22, 2016 #4 If, in Erels example, you change n As Node to JavaObject, you don't need to create jo and can use n.RunMethod("...",...)
If, in Erels example, you change n As Node to JavaObject, you don't need to create jo and can use n.RunMethod("...",...)
Erel B4X founder Staff member Licensed User Longtime User Jan 24, 2016 #5 Daestrum said: If, in Erels example, you change n As Node to JavaObject, you don't need to create jo and can use n.RunMethod("...",...) Click to expand... You are thinking out of the box
Daestrum said: If, in Erels example, you change n As Node to JavaObject, you don't need to create jo and can use n.RunMethod("...",...) Click to expand... You are thinking out of the box
tango Active Member Licensed User Longtime User Jun 14, 2016 #6 hi erel RunMethod("setRotate", Array(Degrees)) what are the other parametres. eg. "setrotate","gettext", etc.
hi erel RunMethod("setRotate", Array(Degrees)) what are the other parametres. eg. "setrotate","gettext", etc.
jmon Well-Known Member Licensed User Longtime User Jun 15, 2016 #7 tango said: hi erel Click to expand... Erel doesn't like the post to be targeted at him. It's an open forum, for everyone to answer tango said: what are the other parametres Click to expand... https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#method.summary
tango said: hi erel Click to expand... Erel doesn't like the post to be targeted at him. It's an open forum, for everyone to answer tango said: what are the other parametres Click to expand... https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#method.summary
Daestrum Expert Licensed User Longtime User Jun 15, 2016 #8 An all purpose sub - not quite what you wanted but flexible to allow for any method call Code: Copy ... Dim l As Label l.Initialize("") l.Text = "Hello" MainForm.RootPane.AddNode(l,20,20,-1,-1) RunMethod(l,"setRotate",Array(45.0)) End Sub Sub RunMethod(n As JavaObject,method As String,args() As Object) n.RunMethod(method,args) End Sub
An all purpose sub - not quite what you wanted but flexible to allow for any method call Code: Copy ... Dim l As Label l.Initialize("") l.Text = "Hello" MainForm.RootPane.AddNode(l,20,20,-1,-1) RunMethod(l,"setRotate",Array(45.0)) End Sub Sub RunMethod(n As JavaObject,method As String,args() As Object) n.RunMethod(method,args) End Sub
eps Expert Licensed User Longtime User Jul 20, 2017 #9 Daestrum said: An all purpose sub - not quite what you wanted but flexible to allow for any method call Code: Copy ... Dim l As Label l.Initialize("") l.Text = "Hello" MainForm.RootPane.AddNode(l,20,20,-1,-1) RunMethod(l,"setRotate",Array(45.0)) End Sub Sub RunMethod(n As JavaObject,method As String,args() As Object) n.RunMethod(method,args) End Sub Click to expand... Thanks for this - I've just re-purposed this and also added a return value as well Code: Copy Sub RunMethod(n As JavaObject,method As String,args() As Object) As Object Return n.RunMethod(method,args) End Sub
Daestrum said: An all purpose sub - not quite what you wanted but flexible to allow for any method call Code: Copy ... Dim l As Label l.Initialize("") l.Text = "Hello" MainForm.RootPane.AddNode(l,20,20,-1,-1) RunMethod(l,"setRotate",Array(45.0)) End Sub Sub RunMethod(n As JavaObject,method As String,args() As Object) n.RunMethod(method,args) End Sub Click to expand... Thanks for this - I've just re-purposed this and also added a return value as well Code: Copy Sub RunMethod(n As JavaObject,method As String,args() As Object) As Object Return n.RunMethod(method,args) End Sub