Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Launch several JavaFX window from Eclipse IDE
Launch several JavaFX window from Eclipse IDE [message #1477389] Mon, 17 November 2014 21:49 Go to next message
Arthur Daussy is currently offline Arthur DaussyFriend
Messages: 14
Registered: September 2014
Junior Member
Hello,

I working on a personal project and I would like to launch multiple JavaFX dialogs (or windows) from a Running Eclipse (even if they can not be displayed at the time). I would like to create those dialogs/windows programmatically since I want to use some Java object collected from the current Eclipse IDE.

To do so, my first idea was to use the FXCanvas in a SWT dialog. However my UI uses a lot of animations which run really slowly in such dialogs (whereas they are really smooth in pure JavaFX application). Am I missing something here or is it a known issue with FXCanvas?

My second idea was to launch a new Application (using your org.eclipse.fx.osgi.util.AbstractJFXApplication) for each dialog. This time everything look nice on the first launch. I even succeed in using java object in my dialogs (using a custom IApplicationContext). However, I failed to launch a second application. Each time I got an IllegalStateException launched from LauncherImpl.launchApplication [1]. So I guess this is a limitation form JavaFX?

My third try was a bit more twisted. I tried to launch pure JavaFX windows from Java code. It looks like this:

com.sun.javafx.application.PlatformImpl.startup(new Runnable() {
@Override
public void run() {
Stage primaryStage = new Stage();
primaryStage.impl_setPrimary(true); // I have tried both using or mevogin this line
Scene scene = .. // Some cone that created a scene
primaryStage.setScene(scene);
primaryStage.setWidth(scene.getWidth());
primaryStage.setHeight(scene.getHeight());
primaryStage.setTitle("A title");
primaryStage.show();
}
});

However my JVM machine crashes with the following error (see detail in attachment):

#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fb6ef0c1441, pid=3455, tid=140420212356864
#
# JRE version: Java(TM) SE Runtime Environment (8.0_40-b07) (build 1.8.0_40-ea-$
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.40-b11 mixed mode linux-amd64 )
# Problematic frame:
# V [libjvm.so+0x671441] JavaThread::last_frame()+0xa1
#
# Failed to write core dump. Core dumps have been disabled. To enable core dump$
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Since I'm using non API and deprecated API code I guess it's not the correct way to do it but I wanted to give it a try.

Could you guive me some leads on how I could achieve tis? (Or tells me that this is a limitation from JavaFX or OSGI)

Anyway thanks for any help that you can give.

Regards,

Arthur Daussy


[1] com.sun.javafx.application.LauncherImpl.launchApplication(Class<? extends Application>, Class<? extends Preloader>, String[])
I would like to know if there is any way to launch several time the same JavaFX application programmatically. For the moment I have try to use your applica
Re: Launch several JavaFX window from Eclipse IDE [message #1477395 is a reply to message #1477389] Mon, 17 November 2014 21:53 Go to previous messageGo to next message
Arthur Daussy is currently offline Arthur DaussyFriend
Messages: 14
Registered: September 2014
Junior Member
Here some extra information on my configuration:
- Luna platform
e(fx)clipse - IDE 1.0.0.201408150702 org.eclipse.fx.ide.feature.feature.group
- JVM java 8u40 x 64
- Linux Minth 17 x64 ( distribution derived from Ubuntu 13.10)
Re: Launch several JavaFX window from Eclipse IDE [message #1477957 is a reply to message #1477389] Tue, 18 November 2014 08:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Look at how FXCanvas does the bootstrap, it does set some internal
fields, I don't think you really want to do this but the following
should work just fine:

-----8<-----
void openFXWindow() {
// Dummy to let FXCanvas init JavaFX appropiately
Shell s = new Shell();
new FXCanvas(s);
s.dispose();

Stage s = new Stage();
// fill your stage
s.show();
}
-----8<-----

I'm using the same trick in my Swing-SWT-Embedding
http://tomsondev.bestsolution.at/2014/02/10/embedding-swing-into-swt-on-java8/

Tom

On 17.11.14 22:49, Arthur Daussy wrote:
> Hello,
>
> I working on a personal project and I would like to launch multiple JavaFX dialogs (or windows) from a Running Eclipse (even if they can not be displayed at the time). I would like to create those dialogs/windows programmatically since I want to use some Java object collected from the current Eclipse IDE.
>
> To do so, my first idea was to use the FXCanvas in a SWT dialog. However my UI uses a lot of animations which run really slowly in such dialogs (whereas they are really smooth in pure JavaFX application). Am I missing something here or is it a known issue with FXCanvas?
>
> My second idea was to launch a new Application (using your org.eclipse.fx.osgi.util.AbstractJFXApplication) for each dialog. This time everything look nice on the first launch. I even succeed in using java object in my dialogs (using a custom IApplicationContext). However, I failed to launch a second application. Each time I got an IllegalStateException launched from LauncherImpl.launchApplication [1]. So I guess this is a limitation form JavaFX?
>
> My third try was a bit more twisted. I tried to launch pure JavaFX windows from Java code. It looks like this:
>
> com.sun.javafx.application.PlatformImpl.startup(new Runnable() {
> @Override
> public void run() {
> Stage primaryStage = new Stage();
> primaryStage.impl_setPrimary(true); // I have tried both using or mevogin this line
> Scene scene = .. // Some cone that created a scene
> primaryStage.setScene(scene);
> primaryStage.setWidth(scene.getWidth());
> primaryStage.setHeight(scene.getHeight());
> primaryStage.setTitle("A title");
> primaryStage.show();
> }
> });
>
> However my JVM machine crashes with the following error (see detail in attachment):
>
> #
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # SIGSEGV (0xb) at pc=0x00007fb6ef0c1441, pid=3455, tid=140420212356864
> #
> # JRE version: Java(TM) SE Runtime Environment (8.0_40-b07) (build 1.8.0_40-ea-$
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.40-b11 mixed mode linux-amd64 )
> # Problematic frame:
> # V [libjvm.so+0x671441] JavaThread::last_frame()+0xa1
> #
> # Failed to write core dump. Core dumps have been disabled. To enable core dump$
> #
> # If you would like to submit a bug report, please visit:
> # http://bugreport.sun.com/bugreport/crash.jsp
> # The crash happened outside the Java Virtual Machine in native code.
> # See problematic frame for where to report the bug.
> #
>
> Since I'm using non API and deprecated API code I guess it's not the correct way to do it but I wanted to give it a try.
>
> Could you guive me some leads on how I could achieve tis? (Or tells me that this is a limitation from JavaFX or OSGI)
>
> Anyway thanks for any help that you can give.
>
> Regards,
>
> Arthur Daussy
>
>
> [1] com.sun.javafx.application.LauncherImpl.launchApplication(Class<? extends Application>, Class<? extends Preloader>, String[])
> I would like to know if there is any way to launch several time the same JavaFX application programmatically. For the moment I have try to use your applica
>
Re: Launch several JavaFX window from Eclipse IDE [message #1478156 is a reply to message #1477957] Tue, 18 November 2014 12:36 Go to previous messageGo to next message
Arthur Daussy is currently offline Arthur DaussyFriend
Messages: 14
Registered: September 2014
Junior Member
Hi,

Thanks a lot ! It's working just fine.

Here is what my final code looks like (if it can help others). I removed all deprecated/non API code:
void openFXWindow(
  Shell s = new Shell();
  new FXCanvas(s, SWT.None);
  s.dispose();

 final Object input = getInput();
  Platform.runLater(new Runnable() {
		@Override
		public void run() {
				...
				Stage primaryStage = new Stage();
				Scene scene = // Build a scene
				primaryStage.setScene(scene);
				primaryStage.setWidth(scene.getWidth());
				primaryStage.setHeight(scene.getHeight());
				primaryStage.setTitle("Titile");
				primaryStage.show();
			}
		});
}


Thanks again,

Arthur Daussy
Re: Launch several JavaFX window from Eclipse IDE [message #1478232 is a reply to message #1478156] Tue, 18 November 2014 14:04 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You don't need runLater! JavaFX and SWT run on the same event-thread!

Tom

On 18.11.14 13:36, Arthur Daussy wrote:
> Hi,
>
> Thanks a lot ! It's working just fine.
>
> Here is what my final code looks like (if it can help others). I
> removed all deprecated/non API code:
>
> void openFXWindow(
> Shell s = new Shell();
> new FXCanvas(s, SWT.None);
> s.dispose();
>
> final Object input = getInput();
> Platform.runLater(new Runnable() {
> @Override
> public void run() {
> ...
> Stage primaryStage = new Stage();
> Scene scene = // Build a scene
> primaryStage.setScene(scene);
> primaryStage.setWidth(scene.getWidth());
> primaryStage.setHeight(scene.getHeight());
> primaryStage.setTitle("Titile");
> primaryStage.show();
> }
> });
> }
>
>
> Thanks again,
>
> Arthur Daussy
>
Re: Launch several JavaFX window from Eclipse IDE [message #1479162 is a reply to message #1478232] Wed, 19 November 2014 07:53 Go to previous message
Arthur Daussy is currently offline Arthur DaussyFriend
Messages: 14
Registered: September 2014
Junior Member
Indeed, it's working just fine without it.

Thanks again,

Arthur
Previous Topic:org.eclipse.e4.core.di.InjectionException error
Next Topic:switching css themes with e(fx)clipse
Goto Forum:
  


Current Time: Thu Apr 25 18:52:20 GMT 2024

Powered by FUDForum. Page generated in 0.03188 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top