JSceneToComponent

107 views
Skip to first unread message

bitman

unread,
Jun 8, 2010, 10:26:39 PM6/8/10
to JFXtras Developers
Hi guys

Apologies if this is a duplicate. Google groups is acting wierd for
me.

I'm not on the dev team, but seeing as you are wrapping up this
current beta up, I just wanted to let you guys know that there are a
HOARD of Java developers hoping you guys come up with a working
JSceneToComponent or similar class that works in JavaFX 1.3.

I'm speaking on behalf of us JavaFX noobs with a decade of Java
experience that don't have the time / energy to become proficient in
JavaFX. We all have existing java apps we want to add say a movie
player to using javafx, nothing too fancy. There is hoards of us old
java guys in this situation. If in any way you can get this baby to
work for us old java guys it'd be GREATLY appreciated. We lost all
hope in Sun, and are all eagerly awaiting the generous development
from you guys

Keep up the fantastic work!

Regards
bit

Pedro Duque Vieira

unread,
Jun 9, 2010, 7:12:39 PM6/9/10
to jfxtr...@googlegroups.com
Hi bitman,

I'm with you on all you've said. Unfortunately Oracle doesn't seem to share
our views on that.

I've attached JXScene working for JavaFX 1.3. Thank Jim Clarke for that.

From what I've tested so far everything seems to be working fine except for
the new preview control: popupmenu. Which I'm going to try to test again if
netbeans decides to cooperate this time :)
And also if you need to set the swing look and feel do it after creating the
JXScene.

Cheers,
Pedro Duque Vieira

Hi guys

Regards
bit

--
You received this message because you are subscribed to the Google Groups
"JFXtras Developers" group.
To post to this group, send email to jfxtr...@googlegroups.com.
To unsubscribe from this group, send email to
jfxtras-dev...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/jfxtras-dev?hl=en.

JXScene.java

bitman

unread,
Jun 10, 2010, 11:30:38 PM6/10/10
to JFXtras Developers
Hi thanks for the file.

I gave it a shot but am getting a weird error I thought you should
know about.

The two lines of code below attempt to get JavaFX movie player scene/
stage that works fine by itself (just one file that plays a
hardcoded .flv file, no frills). It's in it's own JavaFX project under
a package called "mytest"

I've of course added JFXtras-Common-0.7beta2.jar to my library in
Netbeans to my other project, a generic J2EE one, in which I want to
access the other JavaFX file (NewJavaFXClass.fx). I added in these two
lines to my generic J2EE class:

mytest.JXScene jxscene = new mytest.JXScene();
jxscene.setScript("mytest.NewJavaFXClass");

I received this error: Exception in thread "main"
java.lang.ClassCastException: mytest.NewJavaFXClass cannot be cast to
javafx.scene.Scene

I also tried the setStage method of JXScene, same error. In case you
need it, here's the source code of NewJavaFXClass.fx --> http://pastebin.ca/1880903

Thanks
bit

On Jun 9, 3:12 pm, Pedro Duque Vieira <pedro.duquevie...@gmail.com>
wrote:
>  JXScene.java
> 7KViewDownload

Stephen Chin

unread,
Jun 11, 2010, 11:34:14 AM6/11/10
to jfxtr...@googlegroups.com
Pedro,

I integrated your changes into the main codeline. The new scene
extraction technique was not compatible with SceneToJComponent, which I
have deleted.

I made a few minor changes along the way... I changed the name of the
two parameter setScene function to setScript so it is consistent. I
also added some constructor methods so you can do a one line invocation
like this:
JXScene theScene = new JXScene(sceneClass);

It also seems that to get the proper size on layout you need to
initialize the scene contents before the init block by overriding the
children sequence. I updated our sample code to do this.

Finally, I added support for script invocation, so you can simply pass
in a valid JavaFX program and it will extract the Scene from it. This
makes it much easier to integrate with existing JavaFX applications, and
removes some of the guess work around what the JavaFX file has to look
like (it can either extend Scene, extend Stage, or return an instance of
Scene or Stage).

Cheers,
--Steve

P.S.: No more free integrations... you have to check-in the code
yourself next time. :-)

--
--Steve
blog: http://steveonjava.com/

Stephen Chin

unread,
Jun 11, 2010, 11:38:04 AM6/11/10
to jfxtr...@googlegroups.com
Bit,

The problem with your example was that the JavaFX file did not extend
javafx.scene.Scene.

However, I figured that what you were trying to do (simply pointing to a
valid JavaFX application) was pretty common, so I implemented it. Your
example should now work unaltered.

Here is a link to the latest source code if you want to try it out:
http://code.google.com/p/jfxtras/source/browse/common/src/org/jfxtras/scene/JXScene.java

I hope you don't mind, but I also included a modified version of your
sample in our test suite.

Cheers,
--Steve

--
--Steve
blog: http://steveonjava.com/

Pedro Duque Vieira

unread,
Jun 11, 2010, 1:56:00 PM6/11/10
to jfxtr...@googlegroups.com
I've sent Bitman this reply, I thought I was replying to the jfxtras group
but instead went directly through to him.

Hi bit man,

You must create a class that extends Scene hence the ClassCastException:
your javafx class that you're passing to jxscene is a Stage.

I've never managed to get the video working using jxscene. Only made it to
work on Windows XP.
If you want to use javafx video you must reference the jmc.dll. You can do
this with the following arguments: java -Djava.library.path=<path to
jmc.dll file>
I'm guessing it doesn't work on Vista and 7 due to security reasons. As I'm
not an expert on this, I haven't managed a work around, although I haven't
investigated this further.

Cheers,
Pedro DV

Pedro Duque Vieira

unread,
Jun 11, 2010, 2:03:54 PM6/11/10
to jfxtr...@googlegroups.com
Hi Stephen,

"I made a few minor changes along the way... I changed the name of the
two parameter setScene function to setScript so it is consistent. I
also added some constructor methods so you can do a one line invocation
like this:
JXScene theScene = new JXScene(sceneClass);"

Sounds good.

"It also seems that to get the proper size on layout you need to
initialize the scene contents before the init block by overriding the
children sequence. I updated our sample code to do this."

Hum, I don't get this problem. Could you explain it a bit better?

"Finally, I added support for script invocation, so you can simply pass
in a valid JavaFX program and it will extract the Scene from it. This
makes it much easier to integrate with existing JavaFX applications, and
removes some of the guess work around what the JavaFX file has to look
like (it can either extend Scene, extend Stage, or return an instance of
Scene or Stage)."

Also sounds good, but should be noted on the javafx docs or somewhere else
that the stage class and its accompanying configurations won't be taken into
consideration.



"P.S.: No more free integrations... you have to check-in the code
yourself next time. :-)"

Sounds fair :). I haven't done so already because:
1- I'm still testing somethings which aren't working, namely the Popup
javafx preview control.
2- I don't know how to work with the new versioning system. Have to take
sometime to study it but right now I'm very busy trying to get a release of
Modellus(my app) till the end of this month.

Thanks for doing the integration for me :)
Cheers Steve,
Pedro DV

-----Original Message-----
From: jfxtr...@googlegroups.com [mailto:jfxtr...@googlegroups.com] On

Behalf Of Stephen Chin
Sent: sexta-feira, 11 de Junho de 2010 16:34
To: jfxtr...@googlegroups.com
Subject: Re: JSceneToComponent

Pedro Duque Vieira

unread,
Jun 12, 2010, 9:46:10 AM6/12/10
to jfxtr...@googlegroups.com
Hi Steve,

Did you manage to get bitman example which uses video to work? What OS did
you try it in?
With javafx 1.2, video didn't work on vista and 7 when using jxscene.

Cheers,
Pedro DV

-----Original Message-----
From: jfxtr...@googlegroups.com [mailto:jfxtr...@googlegroups.com] On

Behalf Of Stephen Chin
Sent: sexta-feira, 11 de Junho de 2010 16:38
To: jfxtr...@googlegroups.com
Subject: Re: JSceneToComponent

Stephen Chin

unread,
Jun 12, 2010, 3:49:16 PM6/12/10
to jfxtr...@googlegroups.com
Video ran just fine for me on Windows 7 64-bit.

Cheers,
--Steve

Pedro Duque Vieira

unread,
Jun 12, 2010, 3:57:43 PM6/12/10
to jfxtr...@googlegroups.com
Really??

You didn't have to add the jmc dll either?

Stephen Chin

unread,
Jun 12, 2010, 5:07:34 PM6/12/10
to jfxtr...@googlegroups.com
I bootstrapped it through JavaFX (which is cheating slightly):


I tried doing it directly through Java, but I get an UnsatisfiedLinkException even when I pass in jmc.dll (and every other dll in the distribution).

For now bootstrapping seems like the easiest option on Windows.

Cheers,
--Steve
moz-screenshot-7.png

Pedro Duque Vieira

unread,
Jun 13, 2010, 10:14:33 AM6/13/10
to jfxtr...@googlegroups.com

Hi again steve,

 

How do you do the bootstrapping?

Does your solution mean an application cannot start from swing? Or can it start from swing?

 

Cheers, :)

Pedro DV

image001.png

Stephen Chin

unread,
Jun 13, 2010, 10:56:59 AM6/13/10
to jfxtr...@googlegroups.com
If you create and run a simple JavaFX application like this:
JXSceneMovieDemo.main(FX.getArguments());  // replace JXSceneMovieDemo with your main class

It will launch your Swing application and even pass in the arguments from the command line.  Since this is executed through javafx.exe it gets all the correct JavaFX classpath entries and linked libraries for free.

Cheers,
--Steve
Reply all
Reply to author
Forward
0 new messages