Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Swing in JavaFX in SWT(Has anyone tried out embedding Swing in JavaFX in SWT)
Swing in JavaFX in SWT [message #1349958] Mon, 12 May 2014 12:34 Go to next message
Don Smyth is currently offline Don SmythFriend
Messages: 35
Registered: April 2013
Member
Hi All,

I was interested to read Toms Schindl's blog on Embedding Swing into SWT on Java8. I've been testing the Albeiro project and the SWT_AWT bridge and have had problems with both (eg SWT_AWT bridge crash using GTK, refresh issues with Albeiro). Using JavaFX in embedded mode works without issues for me so far. Has anyone encountered any problems with using FXCanvas in embedded mode?

Cheers Don
Re: Swing in JavaFX in SWT [message #1356807 is a reply to message #1349958] Thu, 15 May 2014 08:21 Go to previous messageGo to next message
Christian Ora is currently offline Christian OraFriend
Messages: 20
Registered: May 2014
Junior Member
I've implemented a map-editor in a SwingNode, emmbedded in a FXCanvas, it worked fine so far. But it seems that the MapEditor is reacting slower.
Re: Swing in JavaFX in SWT [message #1356893 is a reply to message #1349958] Thu, 15 May 2014 09:14 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Just one warning on Luna & Gtk! By default Luna uses Gtk3 but JavaFX8
(and AWT/Swing) are linked to Gtk2 [1].

And just for me to understand. You are now embedding JavaFX into SWT and
inside JavaFX you use SwingNode to embed Swing?

Tom

[1]https://bugs.eclipse.org/bugs/show_bug.cgi?id=434869

On 12.05.14 14:34, Don Smyth wrote:
> Hi All,
>
> I was interested to read Toms Schindl's blog on Embedding Swing into SWT
> on Java8. I've been testing the Albeiro project and the SWT_AWT bridge
> and have had problems with both (eg SWT_AWT bridge crash using GTK,
> refresh issues with Albeiro). Using JavaFX in embedded mode works
> without issues for me so far. Has anyone encountered any problems with
> using FXCanvas in embedded mode?
>
> Cheers Don
Re: Swing in JavaFX in SWT [message #1357362 is a reply to message #1356893] Thu, 15 May 2014 13:40 Go to previous messageGo to next message
Don Smyth is currently offline Don SmythFriend
Messages: 35
Registered: April 2013
Member
Yes I was a bit hasty in my comment that all is OK - All works OK until exit... - where as you mention there is a GTK confict:
(SWT:3078): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed
This was using Efxclipse Kepler 4.3.2

I'm using SwingNode eg:

/**
* Based on SwingJavaFxInteroperabilityDemo
* http://www.javaworld.com/article/2074496/core-java/integrating-javafx-2-0-with-swing-and-swt.html
*
*/
...
final FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
final Scene scene = SwingSceneCreator.createSwingScene();
canvas.setScene(scene);
...

public static Scene createSwingScene()
{
final SwingNode swingNode = new SwingNode();
createSwingContent(swingNode);
StackPane pane = new StackPane();
pane.getChildren().add(swingNode);
final Scene swingScene = new Scene(pane, 250, 150);
return swingScene;
}

private static void createSwingContent(final SwingNode swingNode) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
swingNode.setContent(new JButton("Swing button"));
}
});
}

I retried against the eclipse-SDK-4.4M7-linux-gtk-x86_64-efx-1.0.0-SNAPSHOT 15-May-2014 04:24
and got much more serious error:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f68fe90a961, pid=3663, tid=140089735137024
#
# JRE version: Java(TM) SE Runtime Environment (8.0_05-b13) (build 1.8.0_05-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.5-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libgdk-x11-2.0.so.0+0x4f961] gdk_display_open+0x41
#
the fail happens in com.sun.glass.ui.Application on
protected static synchronized void loadNativeLibrary() {
// use the "platform default" name of "glass"
loadNativeLibrary("glass");
}
Cheers

D
Re: Swing in JavaFX in SWT [message #1357381 is a reply to message #1357362] Thu, 15 May 2014 13:48 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 15.05.14 15:40, Don Smyth wrote:
> Yes I was a bit hasty in my comment that all is OK - All works OK until
> exit... - where as you mention there is a GTK confict:
> (SWT:3078): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops !=
> NULL' failed
> This was using Efxclipse Kepler 4.3.2
>
> I'm using SwingNode eg:
>
> /**
> * Based on SwingJavaFxInteroperabilityDemo
> *
> http://www.javaworld.com/article/2074496/core-java/integrating-javafx-2-0-with-swing-and-swt.html
>
> *
> */
> ..
> final FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
> final Scene scene = SwingSceneCreator.createSwingScene();
> canvas.setScene(scene);
> ..
>
> public static Scene createSwingScene()
> {
> final SwingNode swingNode = new SwingNode();
> createSwingContent(swingNode);
> StackPane pane = new StackPane();
> pane.getChildren().add(swingNode);
> final Scene swingScene = new Scene(pane, 250, 150);
> return swingScene; }
> private static void createSwingContent(final SwingNode swingNode) {
> SwingUtilities.invokeLater(new Runnable() {
> @Override
> public void run() {
> swingNode.setContent(new JButton("Swing button"));
> }
> });
> }
>
> I retried against the
> eclipse-SDK-4.4M7-linux-gtk-x86_64-efx-1.0.0-SNAPSHOT 15-May-2014 04:24
> and got much more serious error:

Like I said - on 4.4 you need to force using Gtk2 by setting SWT_GTK3=0
in our env.

Tom
Re: Swing in JavaFX in SWT [message #1359631 is a reply to message #1357381] Fri, 16 May 2014 12:26 Go to previous messageGo to next message
Don Smyth is currently offline Don SmythFriend
Messages: 35
Registered: April 2013
Member
OK, wasn't sure where to set it, there is a blog here:

http://blog.vogella.com/2014/02/21/using-eclipse-luna-on-ubunbu/

On Linux (Efx Kepler and Efx Luna) I still get the message below on exit, on windows there are no problems (Efx Kepler).
(SWT:3116): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed
Re: Swing in JavaFX in SWT [message #1359633 is a reply to message #1359631] Fri, 16 May 2014 12:28 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You need to file a bug against SWT and/or JavaFX.

Tom

On 16.05.14 14:26, Don Smyth wrote:
> OK, wasn't sure where to set it, there is a blog here:
>
> http://blog.vogella.com/2014/02/21/using-eclipse-luna-on-ubunbu/
>
> On Linux (Efx Kepler and Efx Luna) I still get the message below on
> exit, on windows there are no problems (Efx Kepler).
> (SWT:3116): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops !=
> NULL' failed
Re: Swing in JavaFX in SWT [message #1359753 is a reply to message #1359633] Fri, 16 May 2014 13:37 Go to previous message
Don Smyth is currently offline Don SmythFriend
Messages: 35
Registered: April 2013
Member
Done

https://bugs.eclipse.org/bugs/show_bug.cgi?id=435066 - Gtk critical warning when using JavaFX FXCanvas

Cheers

Don
Previous Topic:Problem with Tycho compiling with java8
Next Topic:How to retrieve a Scene in an e4 application?
Goto Forum:
  


Current Time: Tue Apr 16 23:24:12 GMT 2024

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

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

Back to the top