Newbie qs. JavaFx vs Swing?

I looked through the JavaFx introduction and samples, but wish there could be clarification of the following which other developers too might wonder about:
Should I write my app in Swing or Java Fx - what considerations should guide my choice?
It seems that Fx is an alternative or competitor to applets or Google Web toolkit or Flash.
Can you access the file system, work offline?
thanks,
Anil

Yes you're right in that there are many considerations that involved in choosing between JavaFX or Swing (or some other technology) and for the most part a lot of it is just going to come down to opinions rather than hard and fast rules.
First of all, JavaFX applications whether they are deployed as Applets, via Web Start, or with a standalone installer can access the file system, work offline, open sockets etc. The restriction is that if deployed as an Applet or via Web Start the application has to be "signed" and the user has to accept the signed application (click "Yes" on a security warning).
Having said that even unsigned Applets/WebStart applications do have limited access to the file system (a private sandbox) and can open connections back to their originating server. Applets used to be restricted to running in the browser but now they can be dragged out of the browser and "installed" with a shortcut on the users system. The following link provides a good starting point for more information
[http://java.sun.com/javase/6/docs/technotes/guides/jweb/index.html]
Always remember that JavaFX sits on top of Java and often leverages tools, products and technologies to achieve tasks.
In terms of Swing vs JavaFX some of the things you might want to consider are:
Tolerance towards new technologies. Is you organisation able to take something "cutting-edge" and is prepared to work around problems or limitations. Or are the stakeholders in the project so risk-adverse that a more mainstream approach would be better.
Willingness to write code. At this stage you will find that Swing has far more components (widgets) available to it, you can somewhat easily reuse Swing components within JavaFX application but you will need to write and maintain extra code to do so. Also there are other gaps in JavaFX where you'll probably need to write extra code like serialization or dealing with medium-complex event handling (action frameworks). More code appears to have more cost but sometimes you also get the benefit of a better fit to your problem.
But then on the other hand JavaFX is a language dedicated to writing GUIs so you can also argue that even with the current relative immaturity having support within the language for "bind" will result in less code than the the same application written in Swing.
What's the lifespan of this project for you organisation? A short-term one-off project might justify the use of JavaFX through it being not strategic to your organisation. But then on the other hand a large long-term project might also justify the use of JavaFX because it's easier to absorb specialists filling in the gaps of JavaFX in a larger team and also you might see how JavaFX is going to be important into the future (obviously a value based opinion).
What level of "graphics" do you want? The Scene graph within JavaFX makes doing "fancy" graphics, video and animation easier than in Swing.
Hope this helps.
- Richard.

Similar Messages

  • Variable binding with javafx.ext.swing.SwingSlider

    My first javafx program consists of a slider and a text box, the text box displays the current value of the slider. The problem is the text box does not display anything when the program just starts up, but only gets populated once I change the value of the slider. I am not sure what I am doing wrong. Here is the code:
    import javafx.scene.control.*;
    import javafx.scene.*;
    import javafx.stage.*;
    import  javafx.ext.swing.*;
    import javafx.scene.layout.*;
    var BPMSlider = SwingSlider {
        minimum: 10
        maximum: 250
        value: 60
    }; //BPMSlider
    var BPM = bind "{BPMSlider.value}";
    var BPMDisplay = TextBox {
         text: bind BPM
        columns: 3
    }; //BPMDisplay;
    Stage  {
        title: "Slider";
        width: 1000
        height: 500
        visible: true
       // Set the scene
       scene:
           Scene {
           content:       
               HBox{ spacing: 10 content:[ BPMSlider, BPMDisplay ] }
           } // Scene
    }Thanks!

    Hi,
    I don't know how to solve it with binding values, but I managed to solve it with temporary int value which contains Slider.value.
    If any one can help us with solving this binding value we are waiting for answer.
    Here is the code:
    package slider;
    import javafx.ext.swing.*;
    import javafx.scene.*;
    import javafx.scene.control.*;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.*;
    import javafx.stage.*;
    var tempSliderVal:Integer = 60; // temp BPMSlider value
    var BPMSlider = SwingSlider {
        minimum: 10;
        maximum: 250;
        value: bind tempSliderVal with inverse;
        onMouseDragged: function (e:MouseEvent) {
            BPMDisplay.text = tempSliderVal.toString();
        onMouseClicked: function (e:MouseEvent) {
            BPMDisplay.text = tempSliderVal.toString();
    }; //BPMSlider
    var BPMDisplay = TextBox {
         text: tempSliderVal.toString();
        columns: 3;
    }; //BPMDisplay;
    Stage  {
        title: "Slider";
        width: 1000;
        height: 500;
        visible: true;
        // Set the scene
        scene: Scene {
            content: HBox{
                spacing: 10;
                content:[ BPMSlider, BPMDisplay ];
        } // Scene
    }

  • Import javafx.ext.swing.SwingToggleGroup not found in the classpath

    I am trying to run the example here
    Desktop profile
    http://java.sun.com/javafx/1/tutorials/ui/layout/index.html
    but
    import javafx.ext.swing.SwingToggleGroup;
    import javafx.ext.swing.SwingRadioButton;
    here i am having error because
    javafx.ext is not found in my classpath, I am using Netbeans 6.5

    While this shouldn't cause that error, your post is missing a final curly bracket.
    Adding that, it compiles ok in Windows.

  • JavaFx Mobile + Swing Problems

    {color:#000000}{color:#ff0000}{color:#003300}The application runs fine when Run As "Desktop(std. execution mode)" & when changed to Run In "Mobile Emulator" gives following Error :-->{color}
    {color}{color}{color:#ff0000}Error preverifying class javafx.ext.swing.JTextFieldImpl
    java/lang/NoClassDefFoundError: com/sun/javafx/scene/BackgroundSupport$BackgroundSupportable
    ERROR: preverify execution failed, exit code: 1
    {color}{color:#000000}{color:#0000ff}C:\Documents and Settings\pravin.patil\My Documents\NetBeansProjects\ColorSlider\nbproject\build-impl.xml:143: exec returned: -1
    {color}{color:#ff0000}BUILD FAILED (total time: 8 seconds){color}
    How to use Swing components in JavaFX Mobile apps??
    Thanks & Regards,
    Pravin{color}
    Edited by: pravinpatil23 on Mar 30, 2009 3:40 AM

    You can provide visual feedback of clicking.
    Here is a primitive (crude!), naive native button, as an example of such effect. I wanted to make it look like it was physically pressed.
    public class NativeButton extends CustomNode
      var arcSize: Number;
      var message: String;
      var width: Number;
      var height: Number;
      var hole: Rectangle;
      public var displacement: Number;
      override protected function create(): Node
        arcSize = height / 5.0;
        displacement = 3;
        hole = Rectangle
          x: 0, y: 0
          width: width
          height: height
          arcWidth: arcSize,  arcHeight: arcSize
          fill: Color.BLACK
        clip = hole;
        Group
          content:
            hole
            Rectangle
              x: 0, y: 0
              width: width
              height: height
              arcWidth: arcSize,  arcHeight: arcSize
              fill: LinearGradient
                startX: 0.0, startY: 0.0, endX: 1.0, endY: 1.0
                proportional: true
                stops:
                  Stop { offset: 0.0, color: Color.LIGHTBLUE }
                  Stop { offset: 1.0, color: Color.BLUE }
              onMousePressed: ShowPressed
              onMouseReleased: ShowReleased
            Rectangle
              x: height / 9.0, y: height / 9.0
              width: width - 2 * height / 9.0
              height: height * 7 / 9.0
              arcWidth: arcSize,  arcHeight: arcSize
              fill: LinearGradient
                startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
                proportional: true
                stops:
                  Stop { offset: 0.0, color: Color.LIGHTBLUE }
                  Stop { offset: 1.0, color: Color.BLUE }
            Text
              x: width / 7, y: height / 1.4
              content: message
              fill: Color.YELLOW
              font: Font.font(null, FontWeight.BOLD, 36);
      function ShowPressed(e: MouseEvent): Void
        this.translateX = this.translateY = displacement;
        hole.translateX = hole.translateY = -displacement;
    //~     println("Clicked {this}");
      function ShowReleased(e: MouseEvent): Void
        this.translateX = this.translateY = 0;
        hole.translateX = hole.translateY = 0;
    //~     println("Released");
    function run()
    def BASE_SIZE = 300;
    Stage
      title: "Native JavaFX Button"
      scene: Scene
        width:  BASE_SIZE
        height: BASE_SIZE
        fill:   Color.web('#00BABE')
        content:
          Group
            translateX: 20
            translateY: 20
            content:
              NativeButton { message: "Click Me", width: 200, height: 50 }
    }You can add effects, do something on hovering, etc.

  • How to customize a javafx.ext.swing.Panel

    Seid gegrüsst
    I want to customize a javafx.ext.Panel for a little testapplication. It's not possible to use something else, because the customized Panel should be in a ScrollPane.
    How ever, in ordinary java I simply override the public void paint(Graphics g) method and place my drawing routine into it.
    Is there a similar way in javafx to customize a Panel?
    carpe noctem
    livevil

    Hi.
    To answer your question: No.
    When you look into the sources of javafx.ext.swing:
    AbstractPanel (the base class for Panel) does not extend JPanel.
    Instead, it has an attribute of type JPanelImpl (basically a javax.swing.JPanel).
    So there is no chance to influence the paint method's behaviour in the Panel class.
    The only possibility would be to extend the original JPanelImpl (overriding its paint method) and to rewrite AbstractPanel and Panel.
    Regards,
    Jens

  • JavaFX 2 + Swing + Webstart How do we make it as painless as possible

    My team supports a fairly sophisticated swing application and we would love to integrate some FX 2.0 features. Before going too far down that road we’re trying to figure out the best way to minimize the pain for our users.
    I see that fx aware jnlp files can have a fall back launch target however, it seems like the fx aware launch target has to be a full blooded FX application. I created a spike with a simple main and a JFrame and it won’t run.
    For example:
    <jfx:javafx-desc width="100" height="100" main-class="test.MySwingMain" name="Some sample app" />
    If MySwingMain doesnt inherit from Application i get an error.
    In our current application prototypes when you launch Swing plus FX components in them on a computer which does not have FX installed, the application launches fine. It makes no complaints about FX not being installed. However it throws class not found exceptions when you touch any of the fx stuff. I would like to have webstart realize that they don't have fx and allow them to install it but i have only been able to make the default NoJavaFXFallback stuff trigger when the main is in an FX application.
    Is there another way to have my swing application prompt the user to download JavaFX? It may not be possible to allow javascript to do the detection and installation prompt. We would like to handle it at the jnlp/java level but this only seems possible with main classes that inherit from “Application”. Am I missing something?
    I even went so far as to create a FX 2.0 boot strap main class which just creates a swing frame but that behaves strangely when you launch it from webstart.

    Great question for which, unfortunately, I don't have a good answer.
    There is a request for more complete documentation for custom deployments which possibly would have helped you had it existed:
    http://javafx-jira.kenai.com/browse/RT-19981 Enhancements to fallback documentation in Deployment Guide
    This update to the deployment guide is scheduled for 2.2 (release after next).
    Should you have suggestions for missing adjustments to the JavaFX deployment guide, then you can create or comment on documentation jiras or email feedback to:
    [email protected]
    Also, custom FallBack or JavaFX launchers may become a bit easier to create when the sources for JavaFX deployment code (especially the default launcher and fallback class implementations) are made public (I believe that is planned, but not sure when).

  • For my requirements: javafx or swing?

    Hello, I'm starting a project in java.
    The application will be Desktop. Will run in a computer, and will not have internet-acess.
    The application will not require special effects or something like. It will just read and write in a data base. But it must have a good user interface.
    I wish to make this application using javafx, instead of swing or awt.
    Is worth to create this application in javafx? Or I'll get the same results, for my requeriments, that if I use swing?
    Thanks.

    Hi.
    Your persistence must be implemented in java because javafx doesn´t have a DB API yet. Probably your logic/model classes will too. So, no choice.
    About the gui, remember that actually javafx doesn´t have all controls used in typical crud applications (e.g. combobox and table). So, You´ll have to import them from java swing. The javafx declarative gui programming model allows You to implement guis easy and fast but If your gui is not complex and don´t need to be sophisticated I think It´s not a big advantage. Layout in javafx is much better in version 1.2 but, depending on your guis requirements, It still lacks a gridbaglayout-like solution.
    Do a little spike or prototype to help You compare and decide. ;-)
    Cheers

  • 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.

  • Launching JavaFX from Swing as a popup

    We are trying to replace one of our JDialogs in an old Java Swing App with a JavaFX Screen as a proof of concept.
    I went the Interface route and got the JavaFX Screen to pop open from the swing app, but when i close the JavaFX window it kills the Swing App that launched it.
    Any solutions to this?
    Edited by: jmandawg on Jun 22, 2010 8:53 AM

    Is there a way to make the "x" button on a JavaFX desktop window call stage.close() instead of fx.exit() ?

  • Javafx.ext.swing.* unable to import this package in netbeans 6.5

    Hi
    (1) I am not able to get the above package working in Netbeans 6.5. Do I need to install separate plugin to get it?
    When I try to import any swing component, I get error. Any solution to this?
    I tried update the JavaFX plugin, but no positive results. I am using netbeans-6_5-javafx-1_1-windows.
    (2) Is this package supported in mobile devices?
    Regards

    raindrop wrote:
    There are some swing components written on JavaFX on page [Custom Components|http://jfx.wikia.com/wiki/SwingComponents#Custom_Components]
    Well, the idea is to avoid the use of Swing, precisely, since it is not available in the Mobile profile.
    If you mean the Custom Components at the bottom of the page, I think:
    - They should be moved to another page (and linked from this page) as they don't belong to SwingComponents: it is confusing;
    - No offense intended, but they are simplistic (everybody has done such "custom button") and inflexible (hard-coded parameter);
    - Despite previous line, they are nice examples, good samples for beginners. :-) Hey, at least that's a starting point (and better than nothing).

  • Newbie with problem on swing

    hi guys,
    i would like to ask about java swing
    i want to create application without using to many frame
    i.e. i only want to use 1 frame
    let say i have a first page where i ask user to enter an ID and password, then when they click the button the frame stay the same but the component inside the frame will change to other component
    i know there is a way where i can link the different frame but i think it's not a good application
    how can i do it?
    thanks!!

    One way you could do it would be to implement a custom JPanel for each 'screen' of your program. Each JPanel could have a button or buttons which tell the JFrame:
    remove(this);
    add(nextJPanel);
    If your program will use a large number of screens which all look quite similar, you will probably want to create an abstract subclass of JPanel; individual screens would be subclasses of the subclass.

  • How to use Swing Components in  JavaFX

    Hi All,
    I am new to JavaFx. I am trying to use java swing components in javafx.
    I found a sample program in net and tried it. But it shows compile time error.
    Code:
    MySwingComponent .fx
    import javafx.ext.swing.SwingComponent;
    import javax.swing.JComponent;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    * @author nandha
    class MySwingComponent extends SwingComponent{
    var button: JButton;
    public var text: String on replace {
    button.setText(text);
    public var action: function();
    override protected function createJComponent () : JComponent {
    button = new JButton();
    button.addActionListener(ActionListener {
    public override function actionPerformed(e:ActionEvent){
    action();
    return button;
    The above code shows no error.
    Test SwingButton.fx
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import swingcomponents.MySwingButton;
    * @author nandha
    Stage {
    title: "Swing Button Example"
    scene: Scene {
    width: 250
    height: 80
    content: [
    MySwingButton{  // error message: imcompatible type. found MySwingButton. Required javafx.scene.Node[]
    text: "Click Me!"
    action: function(){
    println("Hello World!");
    This code which used the MySwingButton shows error: imcompatible type. found MySwingButton. Required javafx.scene.Node[] - where i have added the MySwingButton.
    Please help me to fix the error.
    Thanks &Regards,
    Nandha K

    Hi Sasa,
    First thanks for your reply.
    I found the problem and have fixed.
    Problem:
    There is no class MySwingButton in the package swingcomponents. Its MySwingComponent that i should have used, which is a big mistake that i have done. To my surprise i don't know NetBeans didn't show any error message at that line.
    Thanks & Regards,
    Nandha K

  • Awt swing javafx integration problem

    Hi !
    i'm trying to "merge" a swing component (an extension of a JPanel) in a personal javafx software.
    Is there any way to achieve my goal?
    Surfing the web i found only how to implement javafx in swing...
    thank you!

    solved by using thingsFx classes (new SwingView(swingComponent)) :)
    http://thingsfx.com/

  • 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

  • JavaFX embedded into Swing applications - success

    For those of you who are trying to use JavaFX within Swing here is an easy way to do it.
    Rectangle rect = new Rectangle();
    rect.$width.setAsDouble(100);
    rect.$height.setAsDouble(100);
    SGNode sgNode = rect.getSGRectangle();
    JSGPanel sgPanel = new JSGPanel();
    sgPanel.setScene(sgNode);
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(sgPanel, BorderLayout.CENTER);The same approach also works for custom nodes you have developed yourself. Note that you can change values of public variables declared in your JavaFX node with e.g. rect.$width.setAsDouble(200.0); When you do this be sure you run the value update code from event dispatch thread.
    I guess this makes JavaFX more usable for us who develop desktop applications with Swing and can't start rewriting everything in JavaFX :-)
    Edited by: aless on Dec 12, 2008 6:51 AM

    aless,
    can you provide concrete example of your approach. im new to fx really unable to follow your example. I tried to follow pmd's explanation but im unable to load the fx classes by the same class loader. Im getting the following error in the runtime
    Thanks and appreciate your help.
    Sri
    Exception in thread "main" java.lang.ClassNotFoundException: test.TestFx
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at test.TestJavaFX.main(TestJavaFX.java:27)
    Profiler Agent: Initializing...
    package test;
    import com.sun.scenario.scenegraph.JSGPanel;
    import com.sun.scenario.scenegraph.SGNode;
    public class TestJavaFX {
    public static void main(String[] args) throws Exception {
    Class c = Class.forName("test.TestFx");
    TestFxInterface test = (TestFxInterface) c.newInstance();
    SGNode sgNode = test.getSGNode();
    JSGPanel sgPanel = new JSGPanel();
    sgPanel.setScene(sgNode);
    package test;
    import com.sun.scenario.scenegraph.SGNode;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.shape.Rectangle;
    public class TestFx extends CustomNode, TestFxInterface {
    public override function create(): Node {
    return Group {
    content: [
    Rectangle {
    x: 10,
    y: 10
    width: 140,
    height: 90
    fill: Color.BLACK
    Circle {
    centerX: 100,
    centerY: 100
    radius: 40
    fill: Color.BLUE
    public override function getSGNode(): SGNode {
    return
    this.impl_getSGNode();
    package test;
    import com.sun.scenario.scenegraph.SGNode;
    public interface TestFxInterface {
    public SGNode getSGNode();
    }

Maybe you are looking for