/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package main; import javafx.animation.TranslateTransition; import javafx.application.Application; import javafx.embed.swing.JFXPanel; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.RadioButton; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.util.Duration; import javax.swing.JFrame; import javax.swing.SwingUtilities; /** * * @author Alessio */ public class SwingApplication extends Application { protected JFXPanel jfxPanel; protected Group group; public static void main(String[] args) { Application.launch(SwingApplication.class, args); } @Override public void start(Stage stage) { Text txt = new Text("TEXT CONTROL"); txt.setTranslateX(50); txt.setTranslateY(20); txt.setUnderline(true); txt.setFont(new Font(20.0)); Label lbl = new Label("LABEL CONTROL"); lbl.setTranslateX(50); lbl.setTranslateY(40); lbl.setFont(new Font(20.0)); RadioButton rdb = new RadioButton("RADIOBUTTON"); rdb.setTranslateX(50); rdb.setTranslateY(80); Button btn = new Button("CLICK ME"); btn.setTranslateX(50); btn.setTranslateY(120); btn.onActionProperty().setValue(new EventHandler() { public void handle(ActionEvent arg0) { Group gr = new Group(); group.getChildren().add(gr); TranslateTransition transition = new TranslateTransition(Duration.millis(2000), gr); transition.setToX(400); transition.play(); } }); group = new Group(txt, lbl, rdb, btn); final Scene scene = new Scene(group, 400, 300); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { jfxPanel = new JFXPanel(); jfxPanel.setScene(scene); JFrame frm = new JFrame(); frm.add(jfxPanel); frm.setSize(400, 300); frm.setTitle("Test"); frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frm.setVisible(true); } }); } }