/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package main; import javafx.embed.swing.JFXPanel; import javafx.event.EventHandler; import javafx.geometry.VPos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; import javafx.scene.text.Font; import javafx.scene.text.Text; import javax.swing.JFrame; public class SwingApplication { /** * @param args the command line arguments */ public static void main(String[] args) { JFrame frame = new JFrame("Test"); final JFXPanel panel = new JFXPanel(); frame.add(panel); frame.setSize(400, 300); com.sun.javafx.application.PlatformImpl.startup(new Runnable() { public void run() { Group root = new Group(); Scene scene = new Scene(root, 250, 80); Text text1 = new Text("Text"); text1.setFont(new Font(48)); text1.setTextOrigin(VPos.TOP); text1.setOnMouseClicked(new EventHandler() { public void handle(MouseEvent event) { System.out.println("Click on Text: "+event.getButton()); } }); root.getChildren().add(text1); panel.setScene(scene); } }); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }