JFXtras/jfxtras-labs

Problem with GroovyFX integration

keilhofer opened this issue · 6 comments

Hi,
I have a problem integrating jfxtras into a groovyfx application.
I tried to add the calendarTextField to a gridpane, but I'm getting
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'CalendarTextField[id=validFromField, styleClass=CalendarTextField]' with class 'jfxtras.labs.scene.control.CalendarTextField' to class 'javafx.scene.Node'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)

I don't understand why the CalenderTextField which is a Control cannot be cast to a Node (superclass).

Can anybody help me with this?

Thanks

tbee commented

Which JavaFX version are you using?

On 2013-04-03 09:49, keilhofer wrote:

Hi,
I have a problem integrating jfxtras into a groovyfx application.
I tried to add the calendarTextField to a gridpane, but I'm getting
|org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'CalendarTextField[id=validFromField, styleClass=CalendarTextField]' with class 'jfxtras.labs.scene.control.CalendarTextField' to class 'javafx.scene.Node'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)|
I don't understand why the CalenderTextField which is a Control cannot be cast to a Node (superclass).

Can anybody help me with this?

Thanks


Reply to this email directly or view it on GitHub #24.

I'm using 2.2.7

tbee commented

Ok. CalendarTextField is a control and according to the Javadoc control extends Node.

https://github.com/JFXtras/jfxtras-labs/blob/2.2/src/main/java/jfxtras/labs/scene/control/CalendarTextField.java
http://docs.oracle.com/javafx/2/api/javafx/scene/control/Control.html

So this is interesting indeed. But I don't see how that class cast can occur.

Tom

On 2013-04-03 11:31, keilhofer wrote:

I'm using 2.2.7


Reply to this email directly or view it on GitHub #24 (comment).

Oahh, I got it... eclipse was cheating me. When I started the application with gradle I got a duplicate node exception. The problem with the groovy integration is, that creating a calendarfield in the gridpane immediately added it to the grid pane (although it is not visible, because I cannot set the row and column in the calendarfield constructor... whereas with the standard text fields of JavaFX one can set row and column of the gridpane in the constructor of the field e.g.
nextCollectionField = textField(text:'', id:'nextCollectionField', disable: true, row:rowNum, column: 1)). although row and column are attributes of the gridpane, not the textfield.
Using calendarField I cannot use the row and column attributes since GroovyFX is not aware of the calendarField somehow. What I did is
registerBeanFactory "calendarTextField", CalendarTextField
but that seems to be not enough...

The problem with the class cast is strange but solved, when I declare it outside of the (GroovyFX) gridpane parentheses.

Did you ever try to integrate jfxtras controls into a GroovyFX application? It would be really nice to be able to use jfxtras in the "groovy way"...
Do you know a way to get the behavior as with the standard JavaFX textfield in GroovyFX for e.g. the CalendarTextField?
Thanks for your help!

forget it, it works... ECLIPSE shows an error, if I do this...
validFromField = calendarTextField(dateFormat: STD_DATE_FORMAT, id:'validFromField', promptText: PROMPT_TEXT_DATE,row:rowNum, column: 1, columnSpan: 2)
whereas it runs perfectly when I run it from gradle / command line....


Maybe I should order a IDEA license...


Sorry for bothering you!! please close the issue...

tbee commented

Good to hear you got it working. I would love to improve JFXtras' controls in Groovy, but there are only so many hours in a day.

Tom

On 2013-04-03 12:18, keilhofer wrote:

Oahh, I got it... eclipse was cheating me. When I started the application with gradle I got a duplicate node exception. The problem with the groovy integration is, that creating a calendarfield in the gridpane immediately added it to the grid pane (although it is not visible, because I cannot set the row and column in the calendarfield constructor... whereas with the standard text fields of JavaFX one can set row and column of the gridpane in the constructor of the field e.g.
|nextCollectionField = textField(text:'', id:'nextCollectionField', disable: true, row:rowNum, column: 1)|). although row and column are attributes of the gridpane, not the textfield.
Using calendarField I cannot use the row and column attributes since GroovyFX is not aware of the calendarField somehow. What I did is
|registerBeanFactory "calendarTextField", CalendarTextField|
but that seems to be not enough...

The problem with the class cast is strange but solved, when I declare it outside of the (GroovyFX) gridpane parentheses.

Did you ever try to integrate jfxtras controls into a GroovyFX application? It would be really nice to be able to use jfxtras in the "groovy way"...
Do you know a way to get the behavior as with the standard JavaFX textfield in GroovyFX for e.g. the CalendarTextField?
Thanks for your help!


Reply to this email directly or view it on GitHub #24 (comment).