package ca.digitalrapids.testjavafx; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Tooltip; import javafx.scene.shape.Rectangle; import javax.swing.JFrame; import javax.swing.SwingUtilities; /** * Hello world! * */ public class App { JFrame frame; JFXPanel fxpanel; public static void main( String[] args ) throws Exception { new App().init(); } private void init() throws Exception { fxpanel = new JFXPanel(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { initSwing(); } }); Platform.runLater(new Runnable() { public void run() { initJavaFX(); } }); } private void initSwing() { frame = new JFrame("JavaFX Test"); frame.setContentPane(fxpanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(320, 240); frame.setVisible(true); } private void initJavaFX() { Group group = new Group(); Scene scene = new Scene(group, 320,240); fxpanel.setScene(scene); Rectangle simpleBox = new Rectangle(30, 30); simpleBox.setStyle("-fx-fill: red;"); group.getChildren().add(simpleBox); Tooltip toolTip = new Tooltip("Hello World!"); Tooltip.install(simpleBox, toolTip); } }