This discussion is archived
6 Replies Latest reply: Jan 14, 2013 12:30 PM by 983574 RSS

how can i put one scene into JPanel of the swing?

983574 Newbie
Currently Being Moderated
how can i put one scene into JPanel of the swing?
  • 1. Re: how can i put one scene into JPanel of the swing?
    jsmith Guru
    Currently Being Moderated
    Take a look at JavaFX for Swing developers:
    http://docs.oracle.com/javafx/2/swing/jfxpub-swing.htm

    Use a JFXPanel to allow a JavaFX scene to be embedded in a Swing application:
    http://docs.oracle.com/javafx/2/api/javafx/embed/swing/JFXPanel.html

    Ensure that the path to the javafx runtime library jfxrt.jar is on your hybrid Swing/JavaFX apps compile and execution library path.
  • 2. Re: how can i put one scene into JPanel of the swing?
    983574 Newbie
    Currently Being Moderated
    ty for the information but i have a problen with JFXpanel when i try to into a panel it doesnt display inside
  • 3. Re: how can i put one scene into JPanel of the swing?
    gimbal2 Guru
    Currently Being Moderated
    980571 wrote:
    ty for the information but i have a problen with JFXpanel when i try to into a panel it doesnt display inside
    Sorry to hear that. If you want assistance with the code, feel free to post the relevant parts of it. Make sure to use \
     tags when you do.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  • 4. Re: how can i put one scene into JPanel of the swing?
    983574 Newbie
    Currently Being Moderated
    ty for the information but i have a problen with JFXpanel when i try to into a panel it doesnt display inside

    for example

    public class Windows extends JFrame

    public Windows()
    {
    super("Windows");

    .......

    JFXPanel jfxp=new JFXPanel();

    setScene(jfxp);

    Panel panel=new Panel();

    this.add(panel);
    this.setVisible(true);
    }


    public void setScene(JFXPanel jfxp)
    {
    BorderPane bp=new BorderPane();

    Scene s=new Scene(bp,400,400);

    jfxp.setScene(s);



    }


    }
  • 5. Re: how can i put one scene into JPanel of the swing?
    jsmith Guru
    Currently Being Moderated
    You have to set the scene (and any other javafx related tasks you do, but no swing related API calls you make) in a Platform.runLater call as shown in the javadoc example from JFXPanel I linked earlier:
    http://docs.oracle.com/javafx/2/api/javafx/embed/swing/JFXPanel.html

    Please format code using tags as outlined in the sticky thread at the top of the forum:
    https://forums.oracle.com/forums/ann.jspa?annID=1622
  • 6. Re: how can i put one scene into JPanel of the swing?
    983574 Newbie
    Currently Being Moderated
    ty for u help man i really appreciate it, i wish u a good luck to all u study

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points