Embedding JavaFX v1.2 Scene's in Swing

Before I start... SUN DOES NOT SUPPORT THIS AND IT IS LIKELY TO CHANGE... hopefully we get official support in a future release, please :)
+"Note: We also recognize the need for the inverse (embedding a JavaFX scene into a Swing app), however that is not supported with 1.2 as it requires a more formal mechanism for manipulating JavaFX objects from Java code. The structure of these JavaFX objects is a moving target (for some very good reasons) and we're not ready to lock that down (yet). However,as with most software, this can be hacked (see Rich & Jasper's hack on Josh's blog) but know that you are laying compatibility down on the tracks if you go there. "+ Source: http://weblogs.java.net/blog/aim/archive/2009/06/insiders_guide.html
But if you really really want this now read on.
After a lengthy investigation and some help from others (including the jfxtra's project) here is how to Embed a JavaFX scene in your Swing application:
First, start your java application with javafx and not java! This will fix any potential class path issues and really does solve a lot of issues you will have 'patching' the JVM with JavaFX (if that is even possible). JavaFX will happily run a Java project (with the JVM) even if there is not one JavaFX class in your project.
Next, you need to create a Java Interface for your JavaFX object to implement:
package mix.javastuff;
* This is a Java Interface that your JavaFX class should implement.
* This will define how Java will interact with your JavaFX class.
* @author ahhughes
public interface TextDisplay {
    public void setText(String text);
}Next, you need to create your JavaFX object... it must extend Scene and you are to provide any interaction with Java you will need to implement a java interface:
package mix.javafxstuff;
import mix.javastuff.TextDisplay;
import javafx.scene.Scene;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.effect.Reflection;
import javafx.scene.text.TextOrigin;
* Here is a very simple scene, that implements a java interface
* That allows Java (or JavaFX) to setText on the Scene's content.
public class TextDisplayJavaFXScene extends Scene , TextDisplay {
    override public function setText(text:String):Void{
        content = Text {
                font : Font {size: 44}
                x: 0, y: 0
                textOrigin: TextOrigin.TOP
                content: text
                effect: Reflection {}
}Finally, you need to use some reflection and some under the hood magic to get your JavaFX object and wrap in in a SwingScene (which just so happens to extend JComponent).
package mix.javastuff;
import com.sun.javafx.tk.swing.SwingScene;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javafx.reflect.FXClassType;
import javafx.reflect.FXContext;
import javafx.reflect.FXFunctionMember;
import javafx.reflect.FXLocal;
import javafx.reflect.FXLocal.ObjectValue;
import javafx.scene.Scene;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
* Example of how to inject JavaFX into your Swing app.
public class Main {
    private static final FXLocal.Context context = FXLocal.getContext();
    private static TextDisplay textDisplayJavaFXScene;// javafx scene & java interface
    public static void main(String[] args) {
        //Get the JavaFX Object, that has 'extends Scene, SomeJavaInterface'
     FXClassType instanceType = context.findClass("mix.javafxstuff.TextDisplayJavaFXScene");
     ObjectValue objectInstance = (ObjectValue) instanceType.newInstance();
     textDisplayJavaFXScene = (TextDisplay) objectInstance.asObject();
        //Wrap this in a SwingScene using refection
        JComponent textDisplayJavaFXSwingScene = sceneInstanceToJComponent((Scene)textDisplayJavaFXScene);
        //Now let's show the JComponent+JavaFXScene in a simple Swing App.
        createSimpleSwingApp(textDisplayJavaFXSwingScene);
     * This method wraps the Scene with a JComponent. This is what you can add
     * to your Swing application.
     * @param scene the JavaFX object that extends javafx.scene.Scene.
     * @return the javafx.scene.Scene wrapped by a JComponent.
     public static JComponent sceneInstanceToJComponent(Scene scene) {
         FXClassType sceneType = FXContext.getInstance().findClass("javafx.scene.Scene");
         ObjectValue obj = FXLocal.getContext().mirrorOf(scene);
         FXFunctionMember getPeer = sceneType.getFunction("impl_getPeer");
         FXLocal.ObjectValue peer = (ObjectValue) getPeer.invoke(obj);
         SwingScene swingScene = (SwingScene)peer.asObject();
         return (JComponent) swingScene.scenePanel;
     * OK, this method is just to show you this in action.... the real stuff
     * you are interested is in the methods above.
     * @param javaFXTextDisplaySwingScene
    private static void createSimpleSwingApp(JComponent javaFXTextDisplaySwingScene){
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setSize(500,500);
         frame.setAlwaysOnTop(true);
          JPanel panel = new JPanel();
          panel.setLayout(new FlowLayout());
        //create a swing interface to interact with textDisplayJavaFXScene.setText()
        final JTextField textInputField = new JTextField("Set THIS Text!");
          panel.add(textInputField);
          JButton button = new JButton("Send to JavaFX!");
          panel.add(button);
          button.addActionListener(new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent e) {
                    textDisplayJavaFXScene.setText(textInputField.getText());
        //add the JavaFX SwingScene to the Swing's JPanel
         panel.add(javaFXTextDisplaySwingScene);
        //display the swing app
         frame.add(panel);
         frame.setVisible(true);
}That's it!

morningstar wrote:
You can refer to this article for how to embeded javaFX scene into SWING:
[JavaFX Scene embedded in SWING Window|http://www.javafxgame.com/javafx-scene-swing-java/]
[http://www.javafxgame.com/javafx-scene-swing-java/|http://www.javafxgame.com/javafx-scene-swing-java/]
Hi morningstar, this article is good and it too helped me out A LOT! It shows how to embed a JavaFX scene in swing but doesn't show you how to interact with JavaFX objects FROM your Java/Swing code. Wrapping the JavaFX node in a SwingScene doesn't offer a way for the Java/Swing code to interact with the underlying JavaFX objects.
How can you set the text in the JavaFX Text node from the Java/Swing code in the linked article? You can't, all you can do is have the JavaFX objects reference BACK to public static fields in your Java code (not the best):
Java Class:
public class JavaFXToSwingTest extends JFrame {
    public static JTextField tf = new JTextField("JavaFX for SWING");
    //other code
JavaFX Class:
    text = JavaFXToSwingTest.tf.getText();  On the other hand, the code in the first post exposes the JavaFX objects through java interfaces as well as wrapping them in a SwingScene. This means that you can do YourJavaFXObject.setText("Blah"); from inside your Java/Swing code, rather handy! :)
Edited by: AndrewHughes on Jul 27, 2009 12:25 AM

Similar Messages

  • Can Eclipse Rich Client Platform embedded javaFX script?

    My application is based on Eclipse Rich Platform Application (RCP), and rcp includes the SWT_AWT bridge,
    which allows RCPs to integrate Swing components as:
    Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
    javax.swing.JPanel panel = new javax.swing.JPanel( );
    frame.add(panel)
    First, I create a JavaFX project, where a subclass of the Scene creates, let's look at the code:
    * Rect.fx
    public class Rect extends Scene {
    init {
    content = [
    Rectangle { width: 200 height: 200 fill: Color.BLUE },
    Text { x: 20 y: 20 content: "Greetings Earthling!" fill: Color.WHITE }
    public function run(args : String[]) {
         Rect {}
    Then, another Plug-in Project has been created a rich client application, and rcp includes the SWT_AWT bridge,
    which allows RCPs to integrate Swing components as:
    Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
    javax.swing.JPanel panel = new javax.swing.JPanel( );
    frame.add(panel)
    There are two lines to create the JavaFX scene to be loaded into a JFrame:
    String sceneClass = "test.Rect";
    JComponent myScene = SceneToJComponent.loadScene(sceneClass);
    The SceneToJComponent class comes from the JFXtras project.
    Its loadScene() method loads a JavaFX Scene class and returns a JComponent object,
    which can be used as a normal Swing JComponent.
    String sceneClass = "test.Rect"; // the main class of the javafx script
    JComponent theScene = SceneToJComponent.loadScene(sceneClass);
    In Rcp application, when try the load the class, this code compiling,
    running and trowing exceptionon console I have the following error:
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jfxtras/scene/SceneToJComponent
    also if this class is present in the classpath of the java project.
    Then I've tried to place this code in simple java application (not eclipse rcp) and all went ok.
    Has anyone tried to include this code in eclipse rich client platform (rcp)?
    Thanks in advance, Best regards
    Shanti

    I have download Java FX2.0 to emebed a scene in a Swing component inside a view of a rcp application, setting the classpath with jfxrt.jar.
    See the following code:
         public void createPartControl(final Composite parent) {
    SwingUtilities.invokeLater(new Runnable() { 
              public void run() { 
    jfxPanel = new JFXPanel();
    createScene();
    but my problem is unresolved, the eclipse console shows the following error:
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
         at test2zero.FxView$1.run(FxView.java:59)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
         at java.awt.EventQueue.access$000(Unknown Source)
         at java.awt.EventQueue$1.run(Unknown Source)
         at java.awt.EventQueue$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel
         at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
         at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
         at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
         at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
         at java.lang.ClassLoader.loadClass(Unknown Source)
    Has anyone ever tried to integrate javafx in eclipse rcp application ?
    Thanks
    Shanti

  • JavaFX Canvas : "fuzzy" lines compared to Swing

    Hi,
    I would very much like to port my Swing application (that draws on a JComponent) to JavaFX. But to my dismay the JavaFX Canvas does not draw as sharp and thin lines as Swing does.
    Lines drawn with the same thickness is noticeably thicker (and "fuzzier") on the JavaFX Canvas than the equivalent Swing lines. I have tested both on Windows (7) and Linux, both 64-bit.
    In my JavaFX app, I proceed like this: gc.beginPath() --> gc.moveTo(..) --> gc.lineTo() --> gc.stroke().
    Is there a setting or something I am missing?

    You need to take into account the coordinate system.
    For further explanation of why this works see the answer to the question below and Node's javadoc:
    http://stackoverflow.com/questions/11881834/what-are-a-lines-exact-dimensions-in-javafx-2
    http://docs.oracle.com/javafx/2/api/javafx/scene/Node.html
    At the device pixel level, integer coordinates map onto the corners and cracks between the pixels and the centers of the pixels appear at the midpoints between integer pixel locations. Because all coordinate values are specified with floating point numbers, coordinates can precisely point to these corners (when the floating point values have exact integer values) or to any location on the pixel. For example, a coordinate of (0.5, 0.5) would point to the center of the upper left pixel on the Stage. Similarly, a rectangle at (0, 0) with dimensions of 10 by 10 would span from the upper left corner of the upper left pixel on the Stage to the lower right corner of the 10th pixel on the 10th scanline. The pixel center of the last pixel inside that rectangle would be at the coordinates (9.5, 9.5).
    import javafx.application.Application;
    import javafx.scene.*;
    import javafx.scene.canvas.*;
    import javafx.stage.Stage;
    /** JavaFX Canvas : "fuzzy" lines compared to Swing JavaFX Canvas : "fuzzy" lines compared to Swing */
    public class FuzzyCanvas extends Application {
      public static void main(String[] args) { launch(args); }
      @Override public void start(Stage stage) {
        Canvas canvas = new Canvas(50, 50);
        GraphicsContext gc = canvas.getGraphicsContext2D();
        gc.beginPath();    // fuzzy line.
        gc.moveTo(10, 30);
        gc.lineTo(20, 30);
        gc.stroke();
        gc.beginPath();    // clean line.
        gc.moveTo(10.5, 39.5);
        gc.lineTo(19.5, 39.5);
        gc.stroke();
        stage.setScene(new Scene(new Group(canvas)));
        stage.show();
    }

  • What makes a JavaFx 1.2 Scene Graph Refresh?

    My first question =). I'm writing a video game with a user interface written in JavaFx. The behavior is correct, but I'm having performance problems. I'm trying to figure out how to figure out what is queuing up the refreshes which are slowing down the app.
    I've done some profiling and believe that the majority of the computation time in my code is spent in JSGPanelRepainter.repaintAll(). Because this is called through a repaint manager, tracing to what is causing the repaintAll to be queued has proven to be challenging. I've read [this post|http://learnjavafx.typepad.com/weblog/2009/04/javafx-performance-tips-from-michael-heinrichs.html] on best practices for performance, but want to be able to identify conclusively what event is causing my performance problem.
    Does anyone have any suggestions on how to trap the event that is queuing up the repaintAll? I'm using Fx 1.2 and programming in Netbeans.

    Basically, anytime you modify the scene graph. Even though the method is called repaintAll, it is only repainting the dirty regions.
    There is no way to trap the event that is queuing up the repaintAll.
    There was an interesting talk at JavaOne about animation timelines and games given by a guy named Peter Pilgrim. He has a blog here

  • Java 8 JRE Embedded + JavaFX on ARM SFP :: How to flip screen

    Hi all,
    How can I flip my screen without using rotate function of my root panel?
    We have an embedded device where the screen is rotated -90°. Then on my root panel I do setRotate(-90); it is OK but when entering a textfield, the embedded virtual keyboard shows not rotated.
    I'm using the java property -Djavafx.platform=directfb so not using X11.
    Thanks!
    M

    Using the package manger in your Linux distribution, try installing libX11 package. We had a similar issue using Java SE 8 embedded on arch Linux as with some distros you are starting from the bare basics and need to add in missing dependencies.

  • JFileChooser problem on MAC OS

    In JavaFX UI on click of Browse button, I am using JFileChooser to open the file system. Below is the piece of code which I am executing and the exception I am getting:
    Later I used DirectoryChooser. This is working fine but the pop-up is always coming behind javafx applet when started in browser.
    Note: This is working fine if we run as stand alone application.
    JFileChooser chooser = new JFileChooser(new File("/Volumes/"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = chooser.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
    System.out.println("selectedFile: "+chooser.getSelectedFile());
    //tfFileSelected.setText(getParent(chooser.getSelectedFile()));
    2013-03-04 10:16:40.480 java[15576:5803] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
    2013-03-04 10:16:42.614 java[15576:707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
    Glass detected outstanding Java exception at -[GlassViewDelegate sendJavaMouseEvent:]:src/com/sun/mat/ui/GlassViewDelegate.m:541
    Exception in thread "AWT-AppKit" java.awt.HeadlessException
         at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
         at java.awt.Window.<init>(Window.java:535)
         at java.awt.Frame.<init>(Frame.java:420)
         at java.awt.Frame.<init>(Frame.java:385)
         at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1759)
         at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1834)
         at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1697)
         at javax.swing.JOptionPane.getWindowForComponent(JOptionPane.java:1638)
         at javax.swing.JFileChooser.createDialog(JFileChooser.java:785)
         at javax.swing.JFileChooser.showDialog(JFileChooser.java:732)
         at javax.swing.JFileChooser.showOpenDialog(JFileChooser.java:639)
         at samplebrowse.SampleBrowse$1.handle(SampleBrowse.java:46)
         at samplebrowse.SampleBrowse$1.handle(SampleBrowse.java:31)
         at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
         at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
         at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
         at javafx.event.Event.fireEvent(Event.java:171)
         at javafx.scene.Node.fireEvent(Node.java:6863)
         at javafx.scene.control.Button.fire(Button.java:179)
         at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
         at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
         at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
         at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
         at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
         at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
         at javafx.event.Event.fireEvent(Event.java:171)
         at javafx.scene.Scene$MouseHandler.process(Scene.java:3324)
         at javafx.scene.Scene$MouseHandler.process(Scene.java:3164)
         at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3119)
         at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1559)
         at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2261)
         at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:228)
         at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
         at com.sun.glass.ui.View.notifyMouse(View.java:922)
    2013-03-04 10:16:44.769 java[15576:707] unrecognized type is -2
    2013-03-04 10:16:44.770 java[15576:707] *** Assertion failure in -[NSEvent _initWithCGSEvent:eventRef:], /SourceCache/AppKit/AppKit-1187.34/AppKit.subproj/NSEvent.m:1348
    2013-03-04 10:16:44.770 java[15576:707] Invalid parameter not satisfying: cgsEvent.type > 0 && cgsEvent.type <= kCGSLastEventType
    2013-03-04 10:16:44.771 java[15576:707] (
         0 CoreFoundation 0x00007fff952af0a6 __exceptionPreprocess + 198
         1 libobjc.A.dylib 0x00007fff93fc13f0 objc_exception_throw + 43
         2 CoreFoundation 0x00007fff952aeee8 +[NSException raise:format:arguments:] + 104
         3 Foundation 0x00007fff8af8e6a2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
         4 AppKit 0x00007fff8c8da56c -[NSEvent _initWithCGSEvent:eventRef:] + 2782
         5 AppKit 0x00007fff8cb5b3ea +[NSEvent eventWithCGEvent:] + 243
         6 libglass.dylib 0x0000000163f4c02f listenTouchEvents + 31
         7 CoreGraphics 0x00007fff919b20d9 processEventTapData + 150
         8 CoreGraphics 0x00007fff919b1f2c _CGYPostEventTapData + 189
         9 CoreGraphics 0x00007fff9191155d _XPostEventTapData + 107
         10 CoreGraphics 0x00007fff91911655 CGYEventTap_server + 106
         11 CoreGraphics 0x00007fff919b201a eventTapMessageHandler + 30
         12 CoreFoundation 0x00007fff9521e410 __CFMachPortPerform + 288
         13 CoreFoundation 0x00007fff9521e2d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
         14 CoreFoundation 0x00007fff9521e019 __CFRunLoopDoSource1 + 153
         15 CoreFoundation 0x00007fff9525119f __CFRunLoopRun + 1775
         16 CoreFoundation 0x00007fff952506b2 CFRunLoopRunSpecific + 290
         17 HIToolbox 0x00007fff8db930a4 RunCurrentEventLoopInMode + 209
         18 HIToolbox 0x00007fff8db92e42 ReceiveNextEventCommon + 356
         19 HIToolbox 0x00007fff8db92cd3 BlockUntilNextEventMatchingListInMode + 62
         20 AppKit 0x00007fff8c7fb613 _DPSNextEvent + 685
         21 AppKit 0x00007fff8c7faed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
         22 AppKit 0x00007fff8c7f2283 -[NSApplication run] + 517
         23 libglass.dylib 0x0000000163f394e9 -[GlassApplication runLoop:] + 777
         24 Foundation 0x00007fff8b014677 __NSThreadPerformPerform + 225
         25 CoreFoundation 0x00007fff9522e101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
         26 CoreFoundation 0x00007fff9522da25 __CFRunLoopDoSources0 + 245
         27 CoreFoundation 0x00007fff95250dc5 __CFRunLoopRun + 789
         28 CoreFoundation 0x00007fff952506b2 CFRunLoopRunSpecific + 290
         29 java 0x0000000109e274bc CreateExecutionEnvironment + 871
         30 java 0x0000000109e21cac JLI_Launch + 1952
         31 java 0x0000000109e27819 main + 101
         32 java 0x0000000109e21504 start + 52
    )

    "Later I used DirectoryChooser. This is working fine but the pop-up is always coming behind javafx applet when started in browser. Note: This is working fine if we run as stand alone applicationYou should file a bug/feature request about this against the Runtime project:
    http://javafx-jira.kenai.com
    Exception in thread "AWT-AppKit" java.awt.HeadlessExceptionSee:
    http://javafx-jira.kenai.com/browse/RT-20784 "Mac: Headless environment issue, MacOSX"
    The above issue discusses some potential workarounds which may (or may not) work in your situation.
    Try the latest 8-ea build (available at http://jdk8.java.net/download.html).
    The graphics environment is no longer forced to be headless in the java 8 trunk (the jira case I linked is closed as fixed), but it may take a week or two for the fix to propagate to the jdk8 early access download page.
    Also note that this kind of call from a JavaFX application to a Swing component isn't really a supported configuration (embedding JavaFX in a JFXPanel in a Swing application is supported, but other forms of interaction between JavaFX and Swing such as JavaFX opening Swing dialogs are not). That's not to say that it might not work, it's just that you shouldn't expect it to work now or continue to work in the future (especially in an applet deployment context where the window handling is more complex for the underlying frameworks due to the browser embedding). Further facilities to ease Swing and JavaFX integration are planned for JavaFX 8 (http://javafx-jira.kenai.com/browse/RT-12100 "Swing components inside JavaFX"), but I don't know if it would mean that the scenario you are trying to achieve would be supported.
    A further alternative you might have would be to deploy your application as a Swing application rather than a JavaFX application and wrap your JavaFX content in a JFXPanel. It is likely that opening a Swing JFileChooser would work in such a mixed code scenario, though I have not tried it.

  • Fixing permissions problem on Mac OS that impedes start of Adobe applications

    See this article for a suggestion for how to deal with a cause of After Effects (and other applications) taking a long time to start on Mac OS:
    fixing permissions problem on Mac OS that impedes start of Adobe applications
    This same issue also affects the functioning of Dynamic Link and warnings regarding QuickTime not being installed.

    "Later I used DirectoryChooser. This is working fine but the pop-up is always coming behind javafx applet when started in browser. Note: This is working fine if we run as stand alone applicationYou should file a bug/feature request about this against the Runtime project:
    http://javafx-jira.kenai.com
    Exception in thread "AWT-AppKit" java.awt.HeadlessExceptionSee:
    http://javafx-jira.kenai.com/browse/RT-20784 "Mac: Headless environment issue, MacOSX"
    The above issue discusses some potential workarounds which may (or may not) work in your situation.
    Try the latest 8-ea build (available at http://jdk8.java.net/download.html).
    The graphics environment is no longer forced to be headless in the java 8 trunk (the jira case I linked is closed as fixed), but it may take a week or two for the fix to propagate to the jdk8 early access download page.
    Also note that this kind of call from a JavaFX application to a Swing component isn't really a supported configuration (embedding JavaFX in a JFXPanel in a Swing application is supported, but other forms of interaction between JavaFX and Swing such as JavaFX opening Swing dialogs are not). That's not to say that it might not work, it's just that you shouldn't expect it to work now or continue to work in the future (especially in an applet deployment context where the window handling is more complex for the underlying frameworks due to the browser embedding). Further facilities to ease Swing and JavaFX integration are planned for JavaFX 8 (http://javafx-jira.kenai.com/browse/RT-12100 "Swing components inside JavaFX"), but I don't know if it would mean that the scenario you are trying to achieve would be supported.
    A further alternative you might have would be to deploy your application as a Swing application rather than a JavaFX application and wrap your JavaFX content in a JFXPanel. It is likely that opening a Swing JFileChooser would work in such a mixed code scenario, though I have not tried it.

  • JavaFx integration in Java swing api

    Hello!
    Can anyone please tell me how to integrate javafx 1.3.1 scene into java swing application.
    Regards, guis.
    Edited by: user7393177 on 2.2.2011 12:25

    You need to have a look at JFXtras 0.7 rc 2 [http://code.google.com/p/jfxtras/] and the org.jfxtras.scene.JXScene class.

  • Cover Flow on JavaFX in Swing GUI

    Speaking staff, all good?
    First I apologize for my bad English!
    Well, the question is as follows. I created a class in JavaFX, where this class requires some common parameters. This class creates a CoverFlow, like when you pick an album on the iPod.
    I would use this class in JavaFX in an interface created in Swing (Java). Is it possible?
    If so, does anyone could give me a hint how to do this? I have no idea nor to the start of it.
    Thank you in advance.
    Hail!

    jfx > java - no problem. you can use java apis without any problems like you've been using them until now.
    java > jfx - compile the jfx classes and then you can use them as library in your java project, i think ;)
    jfx - swing - jfx is using scenario2d java.net project that is entirely written in java so you can use jfx components. better way would be to have gui in jfx, for the future.
    jfx libs - there're already some components in development, but jfx is in its early stage, so things can still change. i don't know about any set of jfx classes that i'd call a animation library. we're rather experimenting yet.

  • JavaFX compared to Swing

    Hi All
    I am trying to work with new JavaFX, I got an experience with Swing, with my first impression it seems that controls like Dialog, messageBox, internalFrame, Frame, Dialog, are not there, maybe because this is the way to make the new RIA looks like web sites, but what are the controls instead of these Swing controls?
    Shlomo.

    There are no specific replacements if you are looking for things like what JOptionPane provided.. you have to build your own dialog with a Stage.

  • How to pass Objects from Java App to JavaFX Application

    Hello,
    New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.
    Any help is appreciated.
    Thanks
    I have my Java app calling my treeviewer JavaFX as
    -- Java Application --
    public class EPMFrame extends JFrame {
    Customer _custObj
    private void categoryAction(ActionEvent e)   // method called by Toolbar
            ocsCategoryViewer ocsFX;    //javaFX treeviewer
            ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.
                                                  // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value
    public class ocsCategoryViewer extends Application {
    String _customer;
    @Override
        public void start(Stage primaryStage) {
         TreeView <String> ocsTree;
         TreeItem <String> root , subcat;
      TreeItem <String> root = new TreeItem <String> ("/");
            root.setExpanded(true);
             ocsTree = new TreeView <String> (root);
             buildTree();     // this uses the Customer Object.
            StackPane stkp_root = new StackPane();
            stkp_root.getChildren().add(btn);
            stkp_root.getChildren().add(ocsTree);
            Scene scene = new Scene(stkp_root, 300, 250);
            primaryStage.setTitle("Tree Category Viewer");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            _customer = args[0];      // temporarily trying to pass in string.
            launch(args);

    JavaFX and Swing integration is documented by Oracle - make sure you understand that before doing further development.
    What are you really trying to do?  The answer to your question depends on the approach you are taking (which I can't really work out from your question).  You will be doing one of:
    1. Run your Swing application and your JavaFX application as different processes and communicate between them.
    This is the case if you have both a Swing application with a main which you launch (e.g. java MySwingApp) and JavaFX application which extends application which you launch independently (e.g. java MyJavaFXApp).
    You will need to do something like open a client/server network socket between the applications and send the data between them.
    2. Run a Swing application with embedded JavaFX components.
    So you just run java MySwingApp.
    You use a JFXPanel, which is "a component to embed JavaFX content into Swing applications."
    3. Run a Java application with embedded Swing components.
    So you just run java MyJavaFXApp.
    You use a SwingNode, which is "used to embed a Swing content into a JavaFX application".
    My recommendation is:
    a. Don't use approach number one and have separate apps written in Swing and Java - that would be pretty complicated and unwarranted for almost all applications.
    b. Don't mix the two toolkits unless you really need to.  An example of a real need is that you have a huge swing app based upon the NetBeans platform and you want to embed a couple of JavaFX graphs in there.  But if your application is only pretty small (e.g., it took less than a month to write), just choose one toolkit or the other and implement your application entirely in that toolkit.  If your entire application is in Swing and you are just using JavaFX because you think its TreeView is easier to program, don't do that; either learn how to use Swing's tree control and use that or rewrite your entire application in JavaFX.  Reasons for my suggestion are listed here: JavaFX Tip 9: Do Not Mix Swing / JavaFX
    c. If you do need to mix the two toolkits, the answer of which approach to use will be obvious.  If you have a huge Swing app and want to embed one or two JavaFX components in it, then use JFXPanel.  If you have a huge JavaFX app and want to embed one or two Swing components in it, use a SwingNode.  Once you do start mixing the two toolkits be very careful about thread processing, which you are almost certain screw up at least during development, no matter how an experienced a developer you are.  Also sharing the data between the Swing and JavaFX components will be trivial as you are now running everything in the same application within the virtual machine and it is all just Java so you can just pass data around as parameters to constructors and method calls, the same way you usually do in a Java program, you can even use static classes and data references to share data but usually a dependency injection framework is better if you are going to do that - personally I'd just stick to simply passing data through method calls.

  • JavaFX and the Netbeans platform

    Hi,
    Quick question...does anyone know if there are any plans or ongoing work to port the netbeans platform to JavaFX?
    Nuwanda

    Nuwanda, take a look at these links, perhaps they can help you:
    http://blogs.oracle.com/geertjan/entry/deeper_integration_of_javafx_in
    http://netbeans.dzone.com/javafx-2-in-netbeans-rcp
    http://blogs.oracle.com/geertjan/entry/a_docking_framework_module_system
    http://blogs.oracle.com/geertjan/entry/thanks_javafx_embedded_browser_for
    I think the Netbeans RCP JavaFX strategy would be to enhance Netbeans RCP to provide better support for embedding JavaFX scenes in the platform.
    Converting the platform to be written in JavaFX rather than Swing would not make much sense - such as thing would actually be a completely new platform in it's own right.

  • Javafx and opengl

    Some body used java opengl with javafx? i read about java3d with javafx but we all informatic student see java3d slow and not efficient
    -Diego

    864728 wrote:
    But you can still do the reverse, embedding JavaFX into a swing application.I have already made this by creating a JFXPanel (which contains a JavaFX scene graph) and adding this one to the JFrame, over a GLCanvas layer.
    But I don't know how to set the JFXPanel position (to the top-right corner for example). I try to apply some translation, but it doesn't work.You'll have to use Swing/AWT features and layouts for that.
    http://download.oracle.com/javase/tutorial/uiswing/layout/index.html
    This is a little problem in my application because I want to show/hide some panels or group of buttons over the GLCanvas...Sounds like a JLayeredPane might help.
    http://download.oracle.com/javase/tutorial/uiswing/components/layeredpane.html
    Any specific problems with that would be better posted in the Swing forum. JFXPanel is a Swing component (it inherits from JComponent).
    db

  • Using javafx and awt together in MAC

    I have read blogs about not using SWT and AWT libraries together in MAC systems. So, are their any constraints for JAVAFX and AWT as well ?
    Please refer to this link.
    I am having a similar case of writing an image to disk and I am using javafx, the line doesn't seem to work on my mac.
    Message was edited by: abhinay_agarwal

    The link you posted on SWT/AWT integration is irrelevant to JavaFX/AWT integration.
    To learn abount JavaFX/Swing integration, see the Oracle tutorial trail:
    JavaFX for Swing Developers: About This Tutorial | JavaFX 2 Tutorials and Documentation
    As Swing is based on AWT, the tutorial trail is equally applicable whether you are integrating JavaFX with only AWT or with the full Swing toolkit.
    In my opinion, there is little reason to integrate JavaFX with just the AWT toolkit as there is little of value that AWT would provide that JavaFX does not already provide.
    JavaFX integrates fine with ImageIO to write files to disk, Oracle provide a tutorial for that (see the "Creating a Snapshot" section):
    Using the Image Ops API | JavaFX 2 Tutorials and Documentation
    //Take snapshot of the scene
    WritableImage writableImage = scene.snapshot(null);
    // Write snapshot to file system as a .png image
    File outFile = new File("imageops-snapshot.png");
    try {
      ImageIO.write(
        SwingFXUtils.fromFXImage(writableImage, null),
        "png",
        outFile
    } catch (IOException ex) {
      System.out.println(ex.getMessage());

  • JavaFX application is cached on client machine

    Hi,
    I have a developed a browser embedded JavaFx application and deployed on a production machine. When I deploy a newer version of .jar file on production machine it is not updated on all client machines because the .jar file is cached. The only way the end user can get latest version of my javafx application is by clearing cache files from java control panel.
    Is there a way I can force my application to always download the latest version of jar file from server?
    Thanks,
    Sridhar

    I have updated the java version on some of the boxes I've tested. I am now noticing that on some PC browsers with IE, the tabbing will only tab them through the browser and not the javafx application.
    I am going to have to deploy as a webstart application for now.
    I will have to work out the kinks later.

Maybe you are looking for

  • How do I keep my downloads from opening 100's of tabs in my browser?

    I tried downloading a free trial of After Effects for the second time; I then tried selecting where I wanted to send it to on my computer, then I clicked the box at the bottom. Next thing I know, it's opening a hundred tabs in my browser a second and

  • Need help with Hard Disk usage selection.

    I am going to get a Mac Pro and I am goint to probably use Final Cut Studio and Photoshop. This is the Hard Disk setup I was thinking of: Bay 1:WD Raptor X 150GB - OS X and some big applications. Bay 2:Stock 250GB - Downloads and some programs Bay 3:

  • Samsung Note 3 not compatible with Share Name ID

    I recently bought a Note 3 and today was trying to change the Share Name ID but it states that it's not compatible with my device. Has anyone else experienced this? I was logged in as account manager as I only have 1 physical voice line on my account

  • Automatic Evaluation Data (Vendor Evaluation)

    Hi Experts, We have defined vendor evaluation in such a way. Price, Quality & Delivery - Automatic Evaluation and Service - Manually Entered. When we do Automatic evaluation thru T-Code ME61, Score of price, quality and delivery appears in the system

  • Controlling #views/#prints and getting audit event notifications

    We have an evaluation of LiveCycle up and running, and we are negotiatons for purchase. In doing some quick proof-of-concept work, we ran across a couple issues we are looking to get help with. Background: We are working in .Net using LiveCycle web s